GET¶
Downloads data files from one of the following internal stage types to a local directory or folder on a client machine:
- 已命名的内部暂存区。
- 指定表的内部暂存区。
- 当前用户的内部暂存区。
You can use this command to download data files after unloading data from a table onto a Snowflake stage using the COPY INTO <location> command.
For more information about using the GET command, see Unload into a Snowflake stage.
- See also:
LIST , PUT , REMOVE , COPY FILES
语法
其中:
必填参数
internalStage指定 Snowflake 中下载文件的位置:
@[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: - namespaceis the database and/or schema in which the named internal stage or table resides. It is optional if adatabase and schema are currently in use within the session; otherwise, it is required. - pathis an optional case-sensitive path for files in the cloud storage location (that is, files have names that begin with acommon string) that limits access to a set of files. Paths are alternatively called prefixes or folders by different cloud storage services. If pathis specified, but no file is explicitly named in the path, all data files in the path aredownloaded. If the stage name or path includes spaces or special characters, it must be enclosed in single quotes (example: '@"my stage"'for a stage named "my stage").file://local_directory_path指定客户端计算机上下载文件所在的本地目录路径:
- Linux/macOS:
You must include the initial forward slash in the path (example:
file:///tmp/load).如果目录路径包含特殊字符,则整个文件 URI 必须放在单引号内。
- Windows:
You must include the drive and backslash in the path (example:
file://C:tempload).If the directory path includes special characters, the entire file URI must be enclosed in single quotes. Note that the drive and path separator is a forward slash (
/) in enclosed URIs (example:'file://C:/Users/%Username%/Data 2025-01').
Note
The GET command returns an error if you specify a filename as part of the path, except if you use the JDBC driver or ODBC driver. If you specify a filename when using either driver, the driver treats the filename as part of the directory path and creates a subdirectory with the specified filename.
For example, if you specify
file:///tmp/load/file.csv, the JDBC or ODBC driver creates a subdirectory namedfile.csv/under the path/tmp/load/. The GET command then downloads the staged files into this new subdirectory.
可选参数
PARALLEL = integer指定用于下载文件的线程数。下载的粒度单位是一个文件。
增加线程数可以提高下载大文件时的性能。
Supported values: Any integer value from
1(no parallelism) to99(use 99 threads for downloading files).Default:
10PATTERN = 'regex_pattern'Specifies a regular expression pattern for filtering files to download. The command lists all files in the specified
pathand applies the regular expression pattern on each of the files found.默认:无值(下载指定暂存区中的所有文件)
使用说明
-
GET does not support the following actions:
-
Downloading files from external stages. To download files from external stages, use the utilities provided by your cloud service.
-
Downloading multiple files with divergent directory paths. The command does not preserve stage directory structure when transferring files to your client machine.
For example, the following GET statement returns an error since you can’t download multiple files named
tmp.parquetthat are in different subdirectories on the stage.
-
-
The ODBC driver supports GET with Snowflake accounts hosted on the following platforms:
- Amazon Web Services(使用 ODBC 驱动程序版本 2.17.5 及更高版本)。
- Google Cloud (using ODBC Driver Version 2.21.5 and higher).
- Microsoft Azure(使用 ODBC 驱动程序版本 2.20.2 及更高版本)。
- The command cannot be executed from the Worksheets
page in either 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.
- 该命令不会重命名文件。
- 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>).
-
For the PUT and GET commands, an EXECUTION_STATUS of
successin the QUERY_HISTORY does _not_ mean that data files were successfully uploaded or downloaded. Instead, the status indicates that Snowflake received authorization to proceed with the file transfer.
示例
Download all files in the stage for the mytable table to the /tmp/data local directory (in a Linux or macOS environment):
Download files from the myfiles path in the stage for the current user to the /tmp/data local directory (in a Linux or
macOS environment):
For additional examples, see Unload into a Snowflake stage.