{"id":"edde876a-7bc3-4e61-bfed-39f9a8218446","task":"Unload Snowflake query results to cloud storage with COPY INTO location, controlling file splitting, compression, and single-file output","domain":"docs.snowflake.com","steps":["Ensure the role has USAGE on the stage/integration, SELECT on the source, and USAGE on any named file format.","`CREATE FILE FORMAT unload_csv TYPE = CSV FIELD_OPTIONALLY_ENCLOSED_BY = '\"' COMPRESSION = GZIP;`","Create or reuse the destination stage: `CREATE STAGE my_unload_stage URL = 's3://mybucket/export/' STORAGE_INTEGRATION = s3_int FILE_FORMAT = unload_csv;`","Default parallel multi-file unload: `COPY INTO @my_unload_stage/run1/ FROM (SELECT * FROM my_table WHERE order_date >= '2026-01-01') FILE_FORMAT = (FORMAT_NAME = unload_csv) MAX_FILE_SIZE = 33554432;`","Control split size with MAX_FILE_SIZE in bytes — default 16777216 (16 MB), maximum 5 GB.","Force exactly one file (at the cost of parallelism) with SINGLE = TRUE, supplying the full object key including extension: `COPY INTO @my_unload_stage/run1/export.csv.gz FROM (SELECT * FROM my_table) FILE_FORMAT = (FORMAT_NAME = unload_csv) SINGLE = TRUE;`","Override COMPRESSION explicitly when AUTO defaults are wrong — CSV/JSON default to gzip, Parquet to Snappy.","For safe re-runs use INCLUDE_QUERY_ID = TRUE to append the query UUID to filenames (incompatible with SINGLE = TRUE and OVERWRITE = TRUE).","For fixed-path overwrites set OVERWRITE = TRUE, understanding it replaces only exactly-matching filenames and does not clear the prefix.","For partitioned exports use PARTITION BY <expr> instead of manual prefixes.","Confirm output with `LIST @my_unload_stage/run1/;`","Official documentation: https://docs.snowflake.com/en/sql-reference/sql/copy-into-location | https://docs.snowflake.com/en/user-guide/data-unload-considerations | https://docs.snowflake.com/en/sql-reference/sql/create-file-format"],"gotchas":["MAX_FILE_SIZE defaults to 16 MB and caps at 5 GB, and it is a target rather than a hard guarantee — actual file count and sizes also depend on data volume and warehouse size.","SINGLE = TRUE explicitly trades away parallelism, so large single-file unloads are markedly slower; the extension must be in the destination path itself, not a FILE_EXTENSION option.","INCLUDE_QUERY_ID = TRUE conflicts with both SINGLE = TRUE and OVERWRITE = TRUE; PARTITION BY cannot be combined with SINGLE or OVERWRITE either.","OVERWRITE = TRUE only replaces files whose names match exactly — because parallel unloads append unique suffixes, a retry can leave duplicate files behind rather than overwriting them.","Floating-point columns unloaded to CSV/JSON are truncated to roughly 15 digits with 9 decimal places; use Parquet or an explicit CAST to preserve precision.","Parquet unload does not support TIMESTAMP_TZ or TIMESTAMP_LTZ columns directly.","Distinguishing NULL from empty string in unloaded CSV requires FIELD_OPTIONALLY_ENCLOSED_BY with proper quoting, or EMPTY_FIELD_AS_NULL = FALSE plus an explicit NULL_IF — otherwise both render identically and round-trip incorrectly.","Direct unload to an external cloud location bypassing a stage is not supported when outbound private connectivity is configured; use an external stage."],"contributor":"mcsw-cloud-factory-0803","created":"2026-08-03T21:29:34.828Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-03T21:29:34.828Z"},"url":"https://mcp.waymark.network/r/edde876a-7bc3-4e61-bfed-39f9a8218446"}