PUT

statementpartialData loading & unloading

docs.snowflake.com ↗

Uploads one or more data files from a local file system onto an internal stage. After you upload files onto an internal stage, you can load data from the files into a table using the COPY INTO <table> command. Note - PUT does not support uploading files onto an external stage. To upload files to an external stage, use the utilities provided by your cloud service. - snowflake.snowpark.FileOperation.put from Snowpark stored procedures does support external stages and bills at normal data transfer rates. - The ODBC driver supports PUT with Snowflake accounts hosted on the following platforms: Amazon Web Services - Google Cloud - Microsoft Azure

Syntax

supportedpartialnot supportednot scored

PUT file://<absolute_path_to_file>/<filename> internalStage
    [ PARALLEL = <integer> ]
    [ AUTO_COMPRESS = TRUE | FALSE ]
    [ SOURCE_COMPRESSION = AUTO_DETECT | GZIP | BZ2 | BROTLI | ZSTD | DEFLATE | RAW_DEFLATE | NONE ]
    [ OVERWRITE = TRUE | FALSE ]

Where

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

Parameters

NameRequiredDescription
file://absolute_path_to_file/filenamerequiredSpecifies the URI for the data files on the client machine, where: absolute_path_to_file is the local directory path to the files to upload. filename is the name of the file to upload. You can use wildcard characters (*, ?) to upload multiple files. If the directory path or filename includes special characters or spaces, enclose the entire file URI in single quotes. Attention Be careful when selecting multiple files using a PUT query. PUT queries that match a large number of files can have significant cost and performance consequences. The URI formatting differs depending on your client operating system. Linux/macOS: Specify the absolute path to the file from the root directory (/). For example, for a file named my-data.csv use file:///my/file/path/my-data.csv. Windows: Specify the absolute path from the root of the drive where the file or files are located. For example, for a file named my-data.csv use file://C:temp\my-data.csv. If the file path includes special characters, you must enclose the entire path in single quotes and change the drive and path separator from a backward slash to a forward slash (/). For example, for a file named my$data.csv, use: 'file://C:/temp/my$data.csv'. Note Snowflake doesn’t support tar (tape archive) files.
internalStagerequiredSpecifies the internal stage location to upload the files onto: @[namespace.]int_stage_name[/path] Files are uploaded onto the specified named internal stage. @[namespace.]%table_name[/path] Files are uploaded onto the stage for the specified table. @~[/path] Files are uploaded onto the stage for the current user.ExpandShow lessSee more Where: <namespace> is the database or schema that contains the named internal stage or table. It is optional if a database and schema are in use within the session. <path> is an optional case-sensitive path for files in the cloud storage location that limits access to a set of files. Paths are alternatively called prefixes or folders by different cloud storage services. If the stage name or path includes spaces or special characters, enclose it in single quotes. For example, use '@"my stage"' for a stage named "my stage". Note Non-English (Unicode) characters aren’t supported in the folder or subpath portion of the target stage path when you upload files using the PUT command or client tools (for example, Snowpark, Snowsight, the Python Connector, or the Snowflake CLI). Folder names (specified as the <path> in @stage/<path>) must consist of English letters, numbers, and a limited set of allowed special characters. Only file names can include non-English (Unicode) characters. Using Unicode characters in the folder portion of the stage path results in a SQL compilation error.
PARALLEL = integeroptionalSpecifies the number of threads to use for uploading files. Snowflake uploads separate batches of data files by size: Files that are smaller than 64 MB (compressed or uncompressed) are staged in parallel as individual files. Larger files are automatically split into chunks, staged concurrently, and reassembled in the target stage. A single thread can upload multiple chunks. Increasing the number of threads can improve performance when uploading large files. Supported values: Any integer value from 1 (no parallelism) to 99 (use 99 threads for uploading files). Default: 4 Note A 16 MB limit applies to older versions of Snowflake drivers, including: JDBC Driver versions prior to 3.12.1. ODBC Driver versions prior to 2.20.5. Python Connector versions prior to 2.2.0.
AUTO_COMPRESS = TRUE | FALSEoptionalSpecifies whether Snowflake uses gzip to compress files during upload: TRUE: Snowflake compresses the files (if they are not already compressed). FALSE: Snowflake doesn’t compress the files. This option does not support other compression types. To use a different compression type, compress the file separately before executing the PUT command. Then, identify the compression type using the SOURCE_COMPRESSION option. Ensure your local folder has sufficient space for Snowflake to compress the data files before staging them. If necessary, set the TEMP, TMPDIR or TMP environment variable in your operating system to point to a local folder that contains additional free space. Default: TRUE
SOURCE_COMPRESSION = AUTO_DETECT | GZIP | BZ2 | BROTLI | ZSTD | DEFLATE | RAW_DEFLATE | NONEoptionalSpecifies the method of compression used on already-compressed files that are being staged: Supported Values Notes AUTO_DETECT Compression algorithm detected automatically, except for Brotli-compressed files, which cannot currently be detected automatically. If you’re uploading Brotli-compressed files, explicitly use BROTLI instead of AUTO_DETECT. GZIP Doesn’t support the *.tar.gz file format. BZ2 Doesn’t support the *.tar.bz2 file format. BROTLI Must be used if uploading Brotli-compressed files. ZSTD Zstandard v0.8 (and higher) supported. DEFLATE Deflate-compressed files (with zlib header, RFC1950). RAW_DEFLATE Raw Deflate-compressed files (without header, RFC1951). NONE Data files have not been compressed.ExpandShow lessSee more Default: AUTO_DETECT Snowflake uses this option to detect how the data files were compressed so that they can be uncompressed and the data extracted for uploading; it does not use this option to compress the files. Loading files that were compressed with other utilities is not currently supported.
OVERWRITE = TRUE | FALSEoptionalSpecifies whether Snowflake overwrites an existing file with the same name during upload: TRUE: An existing file with the same name is overwritten. FALSE: An existing file with the same name is not overwritten. Snowflake performs a LIST operation on the stage in the background, which can affect the performance of the PUT operation. If attempts to PUT a file fail because a file with the same name exists in the target stage, you can take the following actions: Load the data from the existing file into one or more tables, and remove the file from the stage. Then PUT a file with new or updated data onto the stage. Rename the local file, and then attempt the PUT operation again. Set OVERWRITE = TRUE in the PUT statement. Do this only if it’s safe to overwrite the existing (staged) file with the same name. If your Snowflake account is hosted on Google Cloud, PUT statements don’t recognize when the OVERWRITE parameter is set to TRUE. A PUT operation always overwrites any existing files in the target stage with the local files you’re uploading. The following clients support the OVERWRITE option for Snowflake accounts hosted on Amazon Web Services or Microsoft Azure: Snowflake CLI Snowflake ODBC Driver Snowflake JDBC Driver Snowflake Connector for Python Supported values: TRUE, FALSE. Default: FALSE.

Usage notes

Known gaps

Parts not fully supported, and recorded divergences from Snowflake.

See also

Referenced by