Views:
TypeRead/writeAuthorAvailability
Direct providerWriteFinbourneProvided with LUSID

The Drive.File.Operation provider enables you to write a Luminesce query that moves, renames or deletes one or more files in Drive.

Note: The LUSID user running the query must have sufficient access control permissions to both use the provider and modify target files and folders in Drive. This should automatically be the case if you are the domain owner.

See also: Drive.File, Drive.SaveAs

Basic usage

@data = select <data-describing-file-operations-to-perform>;
select * from Drive.File.Operation 
where UpdatesToPerform = @data;

Query parameters

Drive.File.Operation has parameters that enable you to filter or refine a query.

To list available parameters, their data types, default values, and an explanation for each, run the following query using a suitable tool:

select FieldName, DataType, ParamDefaultValue, Description from Sys.Field where TableName = 'Drive.File.Operation' and FieldType = 'Parameter'; 

Basic usage

By default, Drive.File.Operation returns a table of data populated with particular fields (columns). You can return just a subset of these fields if you wish.

To list fields available to return, their data types, whether fields are considered 'main', and an explanation for each, run the following query using a suitable tool:

select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field where TableName = 'Drive.File.Operation' and FieldType = 'Column';

Note: Fields marked 'main' are returned by queries that start select ^ from Drive.File.Operation...

Examples

Note: For more examples, try the Luminesce Github repo.

Example 1: Move a file into a new folder

Any folders specified in NewFullPath are created if they do not already exist. Note: If you do not want existing files to be overwritten, you can instead specify 'MoveRename' as Operation.

@data = select '/luminesce/testing/myfile.csv' as FullPath,
'/luminesce/my-new-folder/myfile.csv' as NewFullPath,
'MoveRenameMayOverwrite' as Operation;

select * from Drive.File.Operation
where UpdatesToPerform = @data; 

Example 2: Rename a file in Drive

Note the filename and path are case-sensitive.

@data = select '/myfile.csv' as FullPath,
'/myrenamedfile.csv' as NewFullPath,
'MoveRenameMayOverwrite' as Operation;

select * from Drive.File.Operation
where UpdatesToPerform = @data; 

Example 3: Rename multiple files

You can specify one or more rows in UpdatesToPerform to move, rename or delete multiple files in one call.

@files_to_rename = values
('/myfile.csv', '/myrenamedfile.csv'),
('/myotherfile.csv', '/myotherrenamedfile.csv');

@table_of_data = select column1 as FullPath, column2 as NewFullPath, 'MoveRenameMayOverwrite' as Operation from @files_to_rename;

select * from Drive.File.Operation
where UpdatesToPerform = @table_of_data; 

Example 4: Delete a file from Drive

@data = select '/myfile.csv' as FullPath,
'Delete' as Operation;

select * from Drive.File.Operation
where UpdatesToPerform = @data;