In this post we are going to cover COPY INTO pointed at a location in Snowflake, which is unloading. The same statement name as the load command, aimed the other way.
You give it a stage path and a table, and it writes the rows out as files. The thing to get straight before anything else is what you are giving it. By default you are giving it a prefix, not a file name, and it decides the name, the number of files and the compression for you.
We will start with the simplest unload there is, look at what landed, and then take those decisions back one option at a time. Every query below was run on a real Snowflake account, and every result you see is the output it gave back.
Episode 128 of the Snowflake SQL: Zero to Hero series on TechBrothersIT.
- Let's create a table worth unloading
- Let's run the simplest unload there is
- Did the data survive the trip?
- Now let's take the compression back
- Now let's keep the column names
- Can we get one file with a name we chose?
- What happens when we ask for a smaller file size?
- Now let's write a folder per region with PARTITION BY
- Can we unload a query instead of a table?
- What happens when the prefix already has a file in it?
- One last thing: the four ways an unload refuses
- And let's put everything back
Let's create a table worth unloading
We need somewhere to write to and something to write. The script below makes a stage, a CSV format and a small sales table across three regions.
-- Sample setup for this post.
-- A stage to write into, a CSV format, and a small table worth unloading.
USE DATABASE DEMO_DB;
USE SCHEMA PUBLIC;
CREATE OR REPLACE STAGE STAGE_T128;
CREATE OR REPLACE FILE FORMAT CSV_T128
TYPE = CSV
FIELD_OPTIONALLY_ENCLOSED_BY = '"';
CREATE OR REPLACE TABLE SALES_T128 (
SALE_ID INT,
REGION VARCHAR(10),
CITY VARCHAR(20),
AMOUNT NUMBER(10,2)
);
INSERT INTO SALES_T128 (SALE_ID, REGION, CITY, AMOUNT) VALUES
(1, 'north', 'Toronto', 100.00),
(2, 'north', 'Boston', 250.50),
(3, 'south', 'Austin', 75.25),
(4, 'south', 'Raleigh', 310.00),
(5, 'south', 'Charlotte', 45.00),
(6, 'east', 'London', 120.75),
(7, 'east', 'Dublin', 88.25),
(8, 'east', 'Zurich', 410.10);SELECT SALE_ID AS SALE_ID, REGION AS REGION, CITY AS CITY, AMOUNT AS AMOUNT
FROM SALES_T128
ORDER BY SALE_ID;| SALE_ID | REGION | CITY | AMOUNT |
|---|---|---|---|
| 1 | north | Toronto | 100.00 |
| 2 | north | Boston | 250.50 |
| 3 | south | Austin | 75.25 |
| 4 | south | Raleigh | 310.00 |
| 5 | south | Charlotte | 45.00 |
| 6 | east | London | 120.75 |
| 7 | east | Dublin | 88.25 |
| 8 | east | Zurich | 410.10 |
Eight rows and four columns. North, south and east.
And the two numbers we are going to check everything against.
SELECT COUNT(*) AS ROWS_IN_THE_TABLE,
SUM(AMOUNT) AS TOTAL_AMOUNT
FROM SALES_T128;| ROWS_IN_THE_TABLE | TOTAL_AMOUNT |
|---|---|
| 8 | 1399.85 |
Eight rows, 1399.85. Whatever we write out, that is what has to come back.
Let's run the simplest unload there is
COPY INTO, then an @ and a stage path, then FROM and the table.
COPY INTO @STAGE_T128/plain/ FROM SALES_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128');| rows_unloaded | input_bytes | output_bytes |
|---|---|---|
| 8 | 207 | 155 |
Three columns back this time, not the ten a load gives you. rows_unloaded, input_bytes and output_bytes. Eight rows unloaded, 207 bytes in and 155 out.
Now let's list that prefix and see what it called the file.
LIST @STAGE_T128/plain/;| name | size | md5 | last_modified |
|---|---|---|---|
| stage_t128/plain/data_0_0_0.csv.gz | 160 | 980308b53f3d04bf6e2ee80b859d5427 | Thu, 1 Oct 2026 18:13:49 GMT |
data_0_0_0.csv.gz. A name nobody chose and a .gz nobody asked for. We gave it a folder and it picked the name, the numbering and the compression.
The unload reported 155 output bytes and the listing reports the object at 160. Those are two different measurements of the same file, from two different commands, and they do not have to agree. This post quotes each number from the grid it came out of and does not treat them as one number.
Did the data survive the trip?
A file that exists is not the same as a file that is right. Let's read it straight back off the stage.
SELECT $1 AS SALE_ID, $2 AS REGION, $3 AS CITY, $4 AS AMOUNT
FROM @STAGE_T128/plain/ (FILE_FORMAT => 'CSV_T128')
ORDER BY $1;| SALE_ID | REGION | CITY | AMOUNT |
|---|---|---|---|
| 1 | north | Toronto | 100.00 |
| 2 | north | Boston | 250.50 |
| 3 | south | Austin | 75.25 |
| 4 | south | Raleigh | 310.00 |
| 5 | south | Charlotte | 45.00 |
| 6 | east | London | 120.75 |
| 7 | east | Dublin | 88.25 |
| 8 | east | Zurich | 410.10 |
All eight rows, all three regions, read back out of a gzipped file without us doing anything about the gzip.
And let's count the two sides against each other in one query.
SELECT (SELECT COUNT(*) FROM SALES_T128) AS ROWS_IN_THE_TABLE,
(SELECT SUM(AMOUNT) FROM SALES_T128) AS TOTAL_IN_THE_TABLE,
(SELECT COUNT(*) FROM @STAGE_T128/plain/
(FILE_FORMAT => 'CSV_T128')) AS ROWS_IN_THE_FILE,
(SELECT SUM($4) FROM @STAGE_T128/plain/
(FILE_FORMAT => 'CSV_T128')) AS TOTAL_IN_THE_FILE;| ROWS_IN_THE_TABLE | TOTAL_IN_THE_TABLE | ROWS_IN_THE_FILE | TOTAL_IN_THE_FILE |
|---|---|---|---|
| 8 | 1399.85 | 8 | 1399.85 |
Eight rows and 1399.85 in the table. Eight rows and 1399.85 in the file. The round trip is clean.
Now let's take the compression back
The .gz is a default, not a requirement. COMPRESSION = NONE goes inside the FILE_FORMAT clause.
COPY INTO @STAGE_T128/plain_nogz/ FROM SALES_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128' COMPRESSION = NONE);| rows_unloaded | input_bytes | output_bytes |
|---|---|---|
| 8 | 207 | 207 |
207 bytes in and 207 out this time, where before it was 155 out.
LIST @STAGE_T128/plain_nogz/;| name | size | md5 | last_modified |
|---|---|---|---|
| stage_t128/plain_nogz/data_0_0_0.csv | 208 | ce898fcecfb2fb10ccf55237cc88e885 | Thu, 1 Oct 2026 18:13:50 GMT |
data_0_0_0.csv. The numbering is still there and still chosen for us, but the .gz has gone.
Now let's keep the column names
Every unload so far has thrown the column names away. HEADER = TRUE keeps them, and it goes on the COPY itself, not in the format.
COPY INTO @STAGE_T128/headed/ FROM SALES_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128' COMPRESSION = NONE)
HEADER = TRUE;| rows_unloaded | input_bytes | output_bytes |
|---|---|---|
| 8 | 242 | 242 |
Let's read that one back with a format that does not skip the header, so the header line shows up as data, and number the lines as we go.
SELECT METADATA$FILE_ROW_NUMBER AS LINE_NUMBER,
$1 AS COLUMN_1, $2 AS COLUMN_2, $3 AS COLUMN_3, $4 AS COLUMN_4
FROM @STAGE_T128/headed/ (FILE_FORMAT => 'CSV_T128')
ORDER BY LINE_NUMBER;| LINE_NUMBER | COLUMN_1 | COLUMN_2 | COLUMN_3 | COLUMN_4 |
|---|---|---|---|---|
| 1 | SALE_ID | REGION | CITY | AMOUNT |
| 2 | 1 | north | Toronto | 100.00 |
| 3 | 2 | north | Boston | 250.50 |
| 4 | 3 | south | Austin | 75.25 |
| 5 | 4 | south | Raleigh | 310.00 |
| 6 | 5 | south | Charlotte | 45.00 |
| 7 | 6 | east | London | 120.75 |
| 8 | 7 | east | Dublin | 88.25 |
| 9 | 8 | east | Zurich | 410.10 |
Line one is SALE_ID, REGION, CITY, AMOUNT. The real column names, in the file. Then the rest of the file underneath it, which makes nine lines for eight rows of data.
This is the loading lesson from Episode 126 arriving from the other direction. A header line is just a line, and whether it is data depends entirely on the format you read it with.
Can we get one file with a name we chose?
We can. SINGLE = TRUE is the option, and it does slightly more than it sounds like.
COPY INTO @STAGE_T128/single/ FROM SALES_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128' COMPRESSION = NONE)
SINGLE = TRUE;| rows_unloaded | input_bytes | output_bytes |
|---|---|---|
| 8 | 207 | 207 |
LIST @STAGE_T128/single/;| name | size | md5 | last_modified |
|---|---|---|---|
| stage_t128/single/data | 208 | 201a4c78cec734e8abe8b5a2afde7a18 | Thu, 1 Oct 2026 18:13:52 GMT |
The file is called data. Not data_0_0_0.csv. Not even data.csv. SINGLE takes the numbering off and the extension with it.
So if you want a real name, you put it in the prefix yourself. Let's end the path with sales_export.csv and keep SINGLE = TRUE.
COPY INTO @STAGE_T128/named/sales_export.csv FROM SALES_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128' COMPRESSION = NONE)
SINGLE = TRUE;| rows_unloaded | input_bytes | output_bytes |
|---|---|---|
| 8 | 207 | 207 |
LIST @STAGE_T128/named/;| name | size | md5 | last_modified |
|---|---|---|---|
| stage_t128/named/sales_export.csv | 208 | 3b93581de93ad02426e341e1f8874fe1 | Thu, 1 Oct 2026 18:13:52 GMT |
sales_export.csv, exactly as written. One file, named by us.
So the headline of this post is about the default. A bare prefix gets you a directory with a generated name in it. A path that names the file, plus SINGLE = TRUE, gets you one file called what you called it. That is the combination to remember when something downstream expects a fixed name.
What happens when we ask for a smaller file size?
The unload reported 207 input bytes. So a MAX_FILE_SIZE of a hundred should give us two or three files. That was my prediction.
COPY INTO @STAGE_T128/split/ FROM SALES_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128' COMPRESSION = NONE)
MAX_FILE_SIZE = 100;| rows_unloaded | input_bytes | output_bytes |
|---|---|---|
| 8 | 207 | 207 |
LIST @STAGE_T128/split/;| name | size | md5 | last_modified |
|---|---|---|---|
| stage_t128/split/data_0_0_0.csv | 208 | b46afc6c8d415b86d9521767909393a0 | Thu, 1 Oct 2026 18:13:53 GMT |
One file. Let's count it properly rather than trust my reading of a listing.
SELECT COUNT(*) AS HOW_MANY_FILES,
SUM("size") AS TOTAL_BYTES
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| HOW_MANY_FILES | TOTAL_BYTES |
|---|---|
| 1 | 208 |
One file, 208 bytes on the stage. Nothing split.
SELECT COUNT(*) AS ROWS_ACROSS_ALL_THE_SPLIT_FILES,
SUM($4) AS TOTAL_ACROSS_ALL_THE_SPLIT_FILES
FROM @STAGE_T128/split/ (FILE_FORMAT => 'CSV_T128');| ROWS_ACROSS_ALL_THE_SPLIT_FILES | TOTAL_ACROSS_ALL_THE_SPLIT_FILES |
|---|---|
| 8 | 1399.85 |
And all eight rows are in it, with the right total.
So MAX_FILE_SIZE is a target Snowflake works towards, not a cap it will break a file to meet. On a table this small there was nothing to split in the first place. I should have expected that, and I did not.
Now let's write a folder per region with PARTITION BY
PARTITION BY is a different idea altogether. It takes an expression, and the value of that expression becomes part of the path.
COPY INTO @STAGE_T128/parts/ FROM SALES_T128
PARTITION BY ('region=' || REGION)
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128' COMPRESSION = NONE);| rows_unloaded | input_bytes | output_bytes |
|---|---|---|
| 8 | 207 | 207 |
Eight rows unloaded, same as always. Now list the prefix.
LIST @STAGE_T128/parts/;| name | size | md5 | last_modified |
|---|---|---|---|
| stage_t128/parts/region=east/data_01c771a5-0308-b568-0010-ea6e0009268a_03_6_0.csv | 80 | f73663edcf3c5126a4223c5f28ee96de | Thu, 1 Oct 2026 18:13:55 GMT |
| stage_t128/parts/region=north/data_01c771a5-0308-b568-0010-ea6e0009268a_03_7_0.csv | 64 | 5a9a61e5a798ceac96a3b89367487579 | Thu, 1 Oct 2026 18:13:55 GMT |
| stage_t128/parts/region=south/data_01c771a5-0308-b568-0010-ea6e0009268a_03_3_0.csv | 96 | 325d76401f886ce7aba55bc65c0bc084 | Thu, 1 Oct 2026 18:13:55 GMT |
Three files, and look at the paths. region=east, region=north, region=south. A folder per value, named key=value, which is the layout every query engine knows how to prune on. And a long id in the file name.
Let's read the whole prefix back and group it by which file each row came out of.
SELECT METADATA$FILENAME AS WHICH_FILE,
COUNT(*) AS ROWS_IN_IT,
SUM($4) AS TOTAL_IN_IT
FROM @STAGE_T128/parts/ (FILE_FORMAT => 'CSV_T128')
GROUP BY METADATA$FILENAME
ORDER BY WHICH_FILE;| WHICH_FILE | ROWS_IN_IT | TOTAL_IN_IT |
|---|---|---|
| parts/region=east/data_01c771a5-0308-b568-0010-ea6e0009268a_03_6_0.csv | 3 | 619.1 |
| parts/region=north/data_01c771a5-0308-b568-0010-ea6e0009268a_03_7_0.csv | 2 | 350.5 |
| parts/region=south/data_01c771a5-0308-b568-0010-ea6e0009268a_03_3_0.csv | 3 | 430.25 |
Three rows in east, two in north, three in south. Those three totals add back up to the 1399.85 we started with.
Can we have SINGLE and PARTITION BY together?
One of those has to give, because one asks for a file and the other asks for a folder tree.
COPY INTO @STAGE_T128/both/ FROM SALES_T128
PARTITION BY ('region=' || REGION)
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128' COMPRESSION = NONE)
SINGLE = TRUE;002328 (22023): SQL compilation error: Invalid copy option 'SINGLE' for partitioned copy unload.
Invalid copy option 'SINGLE' for partitioned copy unload. Refused, and clearly.
Can we unload a query instead of a table?
Yes, and this is where unloading stops being an export and starts being useful. Anything you can SELECT can go straight into a file.
Let's put a whole GROUP BY out to one named file with a header on it.
COPY INTO @STAGE_T128/summary/ FROM (
SELECT REGION,
COUNT(*) AS HOW_MANY,
SUM(AMOUNT) AS TOTAL,
ROUND(AVG(AMOUNT), 2) AS AVERAGE
FROM SALES_T128
GROUP BY REGION
)
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128' COMPRESSION = NONE)
HEADER = TRUE
SINGLE = TRUE;| rows_unloaded | input_bytes | output_bytes |
|---|---|---|
| 3 | 109 | 109 |
Three rows unloaded, which is the number of regions, not the number of sales.
SELECT $1 AS REGION, $2 AS HOW_MANY, $3 AS TOTAL, $4 AS AVERAGE
FROM @STAGE_T128/summary/ (FILE_FORMAT => 'CSV_T128')
ORDER BY $1;| REGION | HOW_MANY | TOTAL | AVERAGE |
|---|---|---|---|
| REGION | HOW_MANY | TOTAL | AVERAGE |
| east | 3 | 619.10 | 206.37 |
| north | 2 | 350.50 | 175.25 |
| south | 3 | 430.25 | 143.42 |
There is the summary. East, north and south with their counts, totals and averages.
That grid has four rows for three regions, and the extra one is the header line. We wrote the file with HEADER = TRUE and read it back with a format that does not skip a header, so the names came through as data again.
What happens when the prefix already has a file in it?
This is the question I actually did not know the answer to. Our very first unload is still sitting in plain/. Let's run that same unload again.
COPY INTO @STAGE_T128/plain/ FROM SALES_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128');001030 (22000): Files already existing at the unload destination: @STAGE_T128/plain/. Use overwrite option to force unloading.
Files already existing at the unload destination. Use overwrite option to force unloading.
So it refuses. It does not add a second file beside the first, and it does not quietly replace it. Both of those would be worse.
LIST @STAGE_T128/plain/;| name | size | md5 | last_modified |
|---|---|---|---|
| stage_t128/plain/data_0_0_0.csv.gz | 160 | 980308b53f3d04bf6e2ee80b859d5427 | Thu, 1 Oct 2026 18:13:49 GMT |
The prefix is unchanged. One file, the same one, the same md5.
Now with OVERWRITE = TRUE
COPY INTO @STAGE_T128/plain/ FROM SALES_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128')
OVERWRITE = TRUE;| rows_unloaded | input_bytes | output_bytes |
|---|---|---|
| 8 | 207 | 155 |
LIST @STAGE_T128/plain/;| name | size | md5 | last_modified |
|---|---|---|---|
| stage_t128/plain/data_0_0_0.csv.gz | 160 | 4e7ea7a00c56b2065276b2109fceb882 | Thu, 1 Oct 2026 18:13:57 GMT |
The same file name and the same size. But the md5 is not the one the listing reported for that file before we overwrote it. Same name, same size, different hash. That is how we know it was replaced and not added to, and the hash is the only thing on that row that tells us.
One last thing: the four ways an unload refuses
Before the refusals, one unload that goes somewhere other than this stage. Your own user stage takes an unload like any other, and SINGLE names it exactly.
COPY INTO @~/t128/sales FROM SALES_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128' COMPRESSION = NONE)
SINGLE = TRUE;| rows_unloaded | input_bytes | output_bytes |
|---|---|---|
| 8 | 207 | 207 |
LIST @~/t128/;| name | size | md5 | last_modified |
|---|---|---|---|
| t128/sales | 208 | 1dbcd7cc6b0c62766ec9a834dbe91bc6 | Thu, 1 Oct 2026 18:13:57 GMT |
t128/sales, the prefix exactly as we wrote it. A user stage is a shared place that nothing in this series cleans up for you, so let's take it straight back out.
REMOVE @~/t128/;| name | result |
|---|---|
| t128/sales | removed |
LIST @~/t128/;| name | size | md5 | last_modified |
|---|
Nothing left. Now the refusals. A stage that does not exist.
COPY INTO @STAGE_T128_NOPE/plain/ FROM SALES_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128');002003 (02000): SQL compilation error: Stage 'DEMO_DB.PUBLIC.STAGE_T128_NOPE' does not exist or not authorized. Your primary role ACCOUNTADMIN or one of your secondary roles must have at least one privilege granted on STAGE DEMO_DB.PUBLIC.STAGE_T128_NOPE.
And a table that does not exist.
COPY INTO @STAGE_T128/nope/ FROM NOT_A_TABLE_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128');002003 (42S02): SQL compilation error: Object 'NOT_A_TABLE_T128' does not exist or not authorized. Your primary role ACCOUNTADMIN or one of your secondary roles must have at least one privilege granted on TABLE NOT_A_TABLE_T128.
Both 002003, but with different SQL states, because one is about where you are writing to and the other is about what you are reading from.
Then a format that cannot be written at all. Episode 125 found this one and it belongs here.
COPY INTO @STAGE_T128/avro/ FROM SALES_T128
FILE_FORMAT = (TYPE = AVRO);002330 (22023): SQL compilation error: Unload not yet implemented for file format 'AVRO'
Unload not yet implemented for file format 'AVRO'. You can read Avro. You cannot write it.
And a max file size of zero, because a zero is always worth trying.
COPY INTO @STAGE_T128/zero/ FROM SALES_T128
FILE_FORMAT = (FORMAT_NAME = 'CSV_T128')
MAX_FILE_SIZE = 0;001008 (22023): SQL compilation error: invalid value [0] for parameter 'MAX_FILE_SIZE'
Refused by value. Good.
And let's put everything back
We have written into eight different prefixes on that stage, so let's see exactly what that adds up to before it goes.
-- Put the schema back the way we found it.
REMOVE @STAGE_T128/;
DROP STAGE IF EXISTS STAGE_T128;
DROP STAGE IF EXISTS STAGE_T128_NOPE;
DROP FILE FORMAT IF EXISTS CSV_T128;
DROP TABLE IF EXISTS SALES_T128;
DROP TABLE IF EXISTS NOT_A_TABLE_T128;REMOVE @STAGE_T128/;| name | result |
|---|---|
| stage_t128/headed/data_0_0_0.csv | removed |
| stage_t128/plain/data_0_0_0.csv.gz | removed |
| stage_t128/summary/data | removed |
| stage_t128/parts/region=east/data_01c771a5-0308-b568-0010-ea6e0009268a_03_6_0.csv | removed |
| stage_t128/parts/region=north/data_01c771a5-0308-b568-0010-ea6e0009268a_03_7_0.csv | removed |
| stage_t128/parts/region=south/data_01c771a5-0308-b568-0010-ea6e0009268a_03_3_0.csv | removed |
| stage_t128/plain_nogz/data_0_0_0.csv | removed |
| stage_t128/split/data_0_0_0.csv | removed |
| stage_t128/single/data | removed |
| stage_t128/named/sales_export.csv | removed |
Ten files from one stage. The plain one, the uncompressed one, the headed one, the single one, the named one, the split one, the summary, and three partition files.
LIST @STAGE_T128/;| name | size | md5 | last_modified |
|---|
SELECT CURRENT_DATABASE() AS THE_DATABASE,
CURRENT_SCHEMA() AS THE_SCHEMA,
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES
WHERE RIGHT(TABLE_NAME, 5) = '_T128') AS PROBE_TABLES_LEFT,
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.STAGES
WHERE STAGE_NAME LIKE '%_T128%') AS PROBE_STAGES_LEFT,
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.FILE_FORMATS
WHERE RIGHT(FILE_FORMAT_NAME, 5) = '_T128') AS PROBE_FORMATS_LEFT,
(SELECT COUNT(*) FROM CUSTOMERS) AS DEMO_DB_IS_READABLE;| THE_DATABASE | THE_SCHEMA | PROBE_TABLES_LEFT | PROBE_STAGES_LEFT | PROBE_FORMATS_LEFT | DEMO_DB_IS_READABLE |
|---|---|---|---|---|---|
| DEMO_DB | PUBLIC | 0 | 0 | 0 | 10 |
No probe tables, no probe stages, no probe formats, and the database still reads.
Key points
- By default
COPY INTO @stage/prefix/writes a directory. It chooses the file name, the numbering and the compression. - An unload returns three columns:
rows_unloaded,input_bytesandoutput_bytes. output_bytesand the size aLISTreports for the same file are two different measurements. Do not treat them as one number.COMPRESSION = NONEdrops the.gz. It goes in the format clause.HEADER = TRUEwrites the column names as the first line. It goes on theCOPY, not in the format.SINGLE = TRUEremoves the numbering and the extension. The file came out calleddata.- To get an exact file name, put it in the prefix and use
SINGLE = TRUE. That gave ussales_export.csv, exactly as written. MAX_FILE_SIZEis a target, not a cap. A limit of a hundred on a table that unloads to207bytes still produced one file.PARTITION BYwriteskey=valuefolders with a generated id in the file name, and it cannot be combined withSINGLE.- A query unloads as easily as a table, so a whole
GROUP BYcan go straight to a file. - Unloading into a prefix that already has a file in it is a refusal,
001030, not an overwrite. OVERWRITE = TRUEreplaces the file. The md5 changing is the proof, because the name and the size do not.
Episode 129 — INFER_SCHEMA and CREATE TABLE ... USING TEMPLATE. Asking a file what shape it is, and building the table from the answer. The answer is made from the data in the file, which turns out to matter a great deal.
Every query and every result grid on this page was captured from a live Snowflake account (version 10.35.101) running the demo script for this episode. The sales data is made up for teaching. This episode writes no local files at all: everything it reads back it unloaded from a table inside the same script, so the right answer is known exactly. The byte counts are Snowflake's own report columns and the file sizes are its own listing column, quoted as they came back. Nothing on this page is timed and no performance claims are made anywhere in this series. The unload behaviour follows the Snowflake COPY INTO <location> documentation.



No comments:
Post a Comment
Note: Only a member of this blog may post a comment.