Skip to main content

Export results to file

Run one SQL statement and write all of its rows to a file (CSV, tab-separated, JSON lines or Parquet), optionally compressed, without holding them all in memory.

Command in the Snowflake toolkit · id ooa.snowflake/export_results · 15 inputs (2 required), 3 outputs

Inputs​

InputTypeRequiredDefaultWhat it is
Account address (URL)StringNoYour Snowflake account address, e.g. https://myorg-myaccount.snowflakecomputing.com.
SQL statementStringYesSQL to run. Put ? where each binding value goes.
FileFileYesFile to write; add .gz yourself when compressing.
BindingsListNoValues for the ? placeholders, in order, e.g. ["2026-10-01"].
FormatStringNocsvcsv (comma-separated, quoted where needed), tsv (tab-separated), json_lines (one JSON object per row) or parquet (columnar, typed; G6).
First row is the headerBooleanNotrueWrite the column names as the first line.
CompressionStringNononenone, or gzip to compress the file. For parquet: auto or snappy (snappy inside the file), gzip, or none. Auto on the other formats compresses with gzip when the file name ends with .gz (G6).
OverwriteBooleanNofalseReplace a file that already exists.
WarehouseStringNoWarehouse that runs the query. Leave empty for the user's default warehouse.
DatabaseStringNoDatabase to use for names that are not fully written out.
SchemaStringNoSchema to use for names that are not fully written out.
RoleStringNoRole to run as. Leave empty for the user's default role.
Wait (seconds)NumberNo3000How long to wait for the statement to finish.
TokenCredentialNoAccess token from the vault: an OAuth token, a key-pair JWT or a programmatic access token. Or leave it empty and choose a connection that signs in, which gets and renews the token.
Token typeStringNoOAUTHKind of token in the vault: OAUTH, KEYPAIR_JWT or PROGRAMMATIC_ACCESS_TOKEN.

Outputs​

OutputTypeWhat it is
fileFileThe file written.
row_countNumberRows written (not counting the header).
statement_handleStringId of the statement.