Data Movement: Loading and Unloading
What candidates must know
Loading is stage-centric: COPY INTO <table> FROM @stage, while unloading is COPY INTO @stage FROM (SELECT ...). Internal stages are the user stage (@~), the table stage (@%tbl) and named stages, populated with PUT/GET; external stages point at S3, Azure or GCS through a storage integration. Expect questions on file formats, PATTERN, ON_ERROR, PURGE, FORCE, VALIDATION_MODE, MATCH_BY_COLUMN_NAME, INFER_SCHEMA with USING TEMPLATE, metadata columns (METADATA$FILENAME, $FILE_ROW_NUMBER) and directory tables refreshed with ALTER STAGE ... REFRESH.
Traps
- Re-running
COPY INTOsilently skips files already loaded in the last 64 days; onlyFORCE = TRUEreloads them. ON_ERRORdefaults toABORT_STATEMENT.CONTINUEloads good rows and reports bad ones;SKIP_FILEdiscards the whole file.VALIDATION_MODEvalidates and reports errors but never loads data.PUT/GETdo not work against external stages, and staged files on external storage are never written byPUT.- Unload requires a stage or external location, not a table name;
SINGLE = TRUEcollapses output into one file and destroys parallel reads.
Rule of thumb
Target roughly 100-250 MB compressed files so each warehouse thread has work; thousands of tiny files mostly add queueing overhead. A bigger warehouse helps with large files, not with a backlog of small ones (use more pipes or Snowpipe instead).
Worked example
A nightly job reports 100 files read, 99 loaded, 1 error. Inspect the COPY result columns and COPY_HISTORY: compare rows_parsed, rows_loaded and errors_seen, run VALIDATION_MODE = RETURN_ERRORS to find the bad row, fix it, then reload with FORCE = TRUE for that file only.