Categories:
DML Commands (by Category) - Data Unloading

GET

Downloads data files from one of the following Snowflake stages to a local directory/folder on a client machine:

  • Named internal stage.
  • Internal stage for a specified table.
  • Internal stage for the current user.

Typically, this command is executed after using the COPY INTO <location> command to unload data from a table into a Snowflake stage.

Note

GET does not support downloading files from named external stages or external locations (i.e. S3 buckets or Azure containers). To download files from external stages/locations, use the utilities provided by S3/Azure.

See also:
LIST , PUT , REMOVE

Syntax

GET internalStage file://<path_to_file>/<filename>
    [ PARALLEL = <integer> ]
    [ PATTERN = '<regex_pattern>'' ]

Where:

internalStage ::=
    @[<namespace>.]<int_stage_name>[/<path>]
  | @[<namespace>.]%<table_name>[/<path>]
  | @~[/<path>]

Required Parameters

internalStage

Specifies the location in Snowflake from which to download the files:

@[namespace.]int_stage_name[/path] Files are downloaded from the specified named internal stage.
@[namespace.]%table_name[/path] Files are downloaded from the stage for the specified table.
@~[/path] Files are downloaded from the stage for the current user.

Where:

  • namespace is the database and/or schema in which the named internal stage or table resides. It is optional if a database and schema are currently in use within the session; otherwise, it is required.
  • The optional path restricts the set of files being downloaded to the files under the folder prefix. If path is specified, but no file is explicitly named in the path, all data files in the path are downloaded.

The string can be enclosed in single quotes, which allows special characters, including spaces, in location names (e.g. '@"my stage"' for a stage named "my stage").

file://path_to_file

Specifies the URI for the data file(s) downloaded to the client machine, where path_to_file is the local directory path where the files are downloaded. If you are downloading the files to the root directory (or sub-directory) on the client machine:

Linux/Mac:You must include the initial forward slash in the path (e.g. file:///tmp/load).
Windows:You must include the drive and backslash in the path (e.g. file://C:\temp\load).

The URI can be enclosed in single quotes, which allows special characters, including spaces, in directory and file names; however, the drive and path separator is a forward slash (/) for all supported operating systems (e.g. 'file://C:/temp/load data' for a path in Windows containing a directory named load data).

Optional Parameters

PARALLEL = integer

Specifies the number of threads to use for downloading the files. The granularity unit for downloading is one file.

Increasing the number of threads can improve performance when downloading large files.

Supported values: Any integer value from 1 (no parallelism) to 99 (use 99 threads for downloading files).

Default: 10

PATTERN = 'regex_pattern'

Specifies a regular expression pattern for filtering files to download.

Default: No value (all files in the specified stage are downloaded)

Usage Notes

  • The command cannot be executed from the Worksheets Worksheet tab page in the Snowflake web interface; instead, use the SnowSQL client to download data files, or check the documentation for the specific Snowflake client to verify support for this command.
  • The command is not currently supported by the ODBC Driver.
  • The command does not rename files.
  • Downloaded files are automatically decrypted using the same key that was used to encrypt the file when it was either uploaded (using PUT) or unloaded from a table (using COPY INTO <location>).

Examples

Download all files in the stage for the mytable table to the /tmp/data local directory (in a Linux or Mac OS environment):

GET @%mytable file:///tmp/data/;

------------+--------+------------+------------+---------+
     file   |  size  |   status   | encryption | message |
------------+--------+------------+------------+---------+
 mydata.csv | 1347   | DOWNLOADED | DECRYPTED  |         |
------------+--------+------------+------------+---------+

Download files with prefix myfiles in the stage for the current user to the /tmp/data local directory (in a Linux or Mac OS environment):

GET @~/myfiles file:///tmp/data/;

---------------------------+---------+------------+------------+---------+
            file           |   size  |   status   | encryption | message |
---------------------------+---------+------------+------------+---------+
 myfiles/orders_001.csv.gz | 1126625 | DOWNLOADED | DECRYPTED  |         |
 myfiles/orders_101.csv.gz | 5214    | DOWNLOADED | DECRYPTED  |         |
----------------------------+--------+------------+------------+---------+