TO_FILE
functionsupportedData loading & unloadingConstructs a value of type FILE from a file location or from metadata.
Syntax
Use one of the following
TO_FILE( <stage_name>, <relative_path> )
TO_FILE( <file_url> )
TO_FILE( <metadata> )
Parameters
| Name | Required | Description |
|---|---|---|
stage_name | required | The name of the stage where the file is located, as a string, in the form '@stage_name'. |
relative_path | required | The path to the file on the stage specified by stage_name as a string. |
file_url | required | A valid stage or scoped file URL as a string. |
metadata | required | An OBJECT containing the required FILE attributes. A FILE must have CONTENT_TYPE, SIZE, ETAG, and LAST_MODIFIED fields. It must also specify the file’s location in one of the following ways: Both STAGE and RELATIVE_PATH STAGE_FILE_URL SCOPED_FILE_URL |
Returns
A FILE that represents the staged file.
Usage notes
- Raises an error when:
- The supplied URL is not valid.
- The file is on a stage that the user lacks privileges to access.
- The supplied metadata doesn’t contain the required FILE fields.
Known limitations
- TO_FILE cannot be used in INSERT INTO TABLE <t> VALUES clause. Use INSERT INTO TABLE <t> SELECT instead.