What you will be able to do
- Use COPY_HISTORY and LOAD_HISTORY to find the files that failed and read their first error
- Pick the ON_ERROR setting (CONTINUE, SKIP_FILE, SKIP_FILE_num, 'SKIP_FILE_num%', ABORT_STATEMENT) that fixes a given failure
- List every error in a file with VALIDATION_MODE = RETURN_ALL_ERRORS, VALIDATE() or VALIDATE_PIPE_LOAD
- Explain why files were skipped or loaded twice, and choose between LOAD_UNCERTAIN_FILES and FORCE
- Use SYSTEM$PIPE_STATUS to find out why a pipe loaded nothing, and repair a stage whose storage integration was recreated
Key concept
Per-file load history — Snowflake records the outcome of every file a COPY statement or pipe processes: a status, row counts and the first error found in that file. Troubleshooting a file load starts from this record. You find the files that failed, read why, then decide whether to fix the data, the options or the setup.
1.Finding failed files in COPY_HISTORY and LOAD_HISTORY
Every file-load investigation starts with the load history, because Snowflake judges each file separately. A COPY over 50 files can load 48, partially load one and fail one. The history has a row per file with a STATUS of Loaded, Partially loaded, Load failed, Load skipped or Load in progress. Next to it are ROW_COUNT (rows loaded), ROW_PARSED (rows read) and FIRST_ERROR_MESSAGE. For any file that did not load completely, that last column says why.
SELECT file_name, status, row_count, first_error_message, last_load_time
FROM TABLE(mydb.INFORMATION_SCHEMA.COPY_HISTORY(
TABLE_NAME => 'myschema.orders',
START_TIME => DATEADD('hour', -24, CURRENT_TIMESTAMP())))
ORDER BY last_load_time DESC;Which history you query depends on how the data arrived. The COPY_HISTORY table function covers both COPY INTO statements and Snowpipe for the last 14 days. The LOAD_HISTORY view covers only COPY INTO. A Snowpipe file will never show up there, however long you look. The Information Schema version of LOAD_HISTORY also stops at 10,000 rows. For older loads, use the Account Usage views: COPY_HISTORY for anything, or LOAD_HISTORY, which keeps a year of COPY loads.
| Source | Covers | Window | Watch out for |
|---|---|---|---|
| INFORMATION_SCHEMA.COPY_HISTORY (table function) | COPY INTO and Snowpipe | Last 14 days | Omits loads by a pipe that was dropped or recreated |
| INFORMATION_SCHEMA.LOAD_HISTORY (view) | COPY INTO only | Last 14 days | No Snowpipe loads; upper limit of 10,000 rows |
| ACCOUNT_USAGE.LOAD_HISTORY (view) | COPY INTO only | Last 365 days | No Snowpipe loads |
| ACCOUNT_USAGE.COPY_HISTORY (view) | COPY INTO and Snowpipe | Beyond 14 days | Use it for older loads and for dropped or recreated pipes |
Some runs leave no history at all, and that tells you something too. Both history sources include only COPY commands that ran to completion, with or without errors. A statement that ON_ERROR = ABORT_STATEMENT terminated was rolled back, so you search QUERY_HISTORY for it instead. History also resets. After a truncate it shows only later loads, and dropping or recreating a pipe removes that pipe's history from the table function.
The first error comes with its position. FIRST_ERROR_LINE_NUMBER, FIRST_ERROR_CHARACTER_POS and FIRST_ERROR_COLUMN_NAME show where in the file it was, and ERROR_COUNT shows how many rows are affected. A parse error on line 1 of every file usually points to a format setting, not bad data. The option that fixes it is covered in File format objects, compression and parsing options.
One symptom looks like a load problem but is not. A DEFAULT CURRENT_TIMESTAMP column records times earlier than the history's LOAD_TIME. That happens because CURRENT_TIMESTAMP is evaluated when the load is compiled, not when it commits. Use METADATA$START_SCAN_TIME when you need a more accurate load time per record.
Checkpoint 1 of 9· Fill the gap
The orders table gets data from bulk COPY INTO jobs and from a Snowpipe. You want each file's status and first error for both kinds of load over the last 24 hours. Which function completes the query?
SELECT file_name, status, row_count, first_error_message, last_load_time
FROM TABLE(mydb.INFORMATION_SCHEMA. ? (
TABLE_NAME => 'myschema.orders',
START_TIME => DATEADD('hour', -24, CURRENT_TIMESTAMP())))
ORDER BY last_load_time DESC;The COPY_HISTORY table function covers both COPY INTO statements and Snowpipe loads from the last 14 days. LOAD_HISTORY covers only COPY INTO, so Snowpipe files never show up in it. QUERY_HISTORY lists statements, not the outcome of each file.
Source: docs.snowflake.com2.Choosing the ON_ERROR setting that fits the failure
ON_ERROR sets what a COPY does when a row fails (Bulk loading with COPY INTO (ON_ERROR, VALIDATION_MODE)). Many loads fail because this setting doesn't match the data. The first thing to check is the default, because it differs between the two file-loading mechanisms. A bulk COPY INTO with no ON_ERROR uses ABORT_STATEMENT. Snowpipe uses SKIP_FILE. So the same bad row stops a whole bulk load, but in a pipe it only fails the one file that contains it.
| Value | Effect | When it wins |
|---|---|---|
| ABORT_STATEMENT (bulk default) | Stops the load if any error is found in a data file | All-or-nothing loads where partial data is worse than none |
| CONTINUE | Loads the good rows of every file; returns at most one error message per file | Keep loading past malformed rows and count rejects afterwards |
| SKIP_FILE (Snowpipe default) | Skips any file containing an error; buffers every file, so it is slower | Files that must load whole or not at all |
| SKIP_FILE_num, e.g. SKIP_FILE_10 | Skips a file when its error rows equal or exceed the number | Tolerate a fixed count of bad rows per file |
| 'SKIP_FILE_num%', e.g. 'SKIP_FILE_10%' | Skips a file when its percentage of error rows exceeds the percentage | Drop only genuinely corrupt files from a mixed batch |
CONTINUE is the setting to use when the load must keep going and you need the rejects counted. The COPY output gives ROWS_PARSED and ROWS_LOADED for each file, and the difference is the number of rows with detected errors. One rejected row may contain several errors, and only one error message per file is returned. Use the tools in the next section when you need all of them.
The skip variants work at the file level. Plain SKIP_FILE throws away a 2 GB file over one bad row. Because it buffers every file, it also wastes credits on large clean ones. With no logical boundary between files, CONTINUE is usually the better choice. Where a few files really are corrupt, 'SKIP_FILE_10%' keeps files with a low error rate and drops only those where more than 10% of rows fail. ABORT_STATEMENT stops at the first error, so no threshold is ever evaluated.
Neither of two common detours gives a per-file reject count after a real load. VALIDATION_MODE only checks the files and loads no data. SYSTEM$PIPE_STATUS reports on a pipe, not on a COPY statement you ran yourself.
Checkpoint 2 of 9· Check yourself
A team moves a nightly bulk COPY INTO, which has no ON_ERROR option, into a pipe and keeps the same COPY statement. In the next batch, one of 50 staged files has a malformed row. How does the pipe handle that batch?
A pipe with no ON_ERROR uses SKIP_FILE, so it rejects only the file that contains the error. A bulk COPY with no ON_ERROR uses ABORT_STATEMENT, which stops the whole load. Loading the good rows of a file needs CONTINUE, and none of these settings sends rows to an error table.
“By default (ON_ERROR = SKIP_FILE), Snowpipe doesn’t load a file that contains errors, and the file has the Load failed status.”Source: docs.snowflake.com
Checkpoint 3 of 9· Exam question
A data engineer runs a COPY INTO statement against 50 staged CSV files without specifying VALIDATION_MODE. The load must keep processing even when individual rows are malformed, and after it finishes the engineer needs to know how many rows were rejected from each file. Which approach satisfies both requirements?
Correct answer: A — Set ON_ERROR = CONTINUE in the COPY statement, then compare the ROWS_PARSED and ROWS_LOADED columns returned by the COPY command to calculate how many rows were rejected per file.
- A. This is correct.
ON_ERROR = CONTINUEloads every row it can parse and skips the bad ones rather than stopping, and the COPY command's result set includesROWS_PARSEDandROWS_LOADEDper file, so the difference tells you exactly how many rows were rejected. - B.
SKIP_FILEdiscards an entire file once any error is found, which throws away rows that would otherwise have loaded, so it does not satisfy "keep processing malformed rows."VALIDATION_MODEalso never loads data, so it cannot recover row counts from a skipped file. - C.
ABORT_STATEMENTrolls back the whole file's load as soon as one error appears, so no rows persist for that file at all; there is nothing partial forLOAD_HISTORYto report, which defeats the continue-processing requirement. - D. The bulk-load default for
ON_ERRORisABORT_STATEMENT, not a continue-on-error mode, so omitting the option does not meet the requirement.SYSTEM$PIPE_STATUSalso reports pipe state for Snowpipe, not row-level results for a manual COPY statement.
Checkpoint 4 of 9· Exam question
A nightly batch load ingests large files where a small number of genuinely corrupt files exist among otherwise clean files. The team wants a corrupt file skipped only once its error rate crosses a meaningful threshold, rather than skipping a whole file over a single bad row or aborting the entire load. Which ON_ERROR configuration matches this requirement?
Correct answer: A — Use ON_ERROR = SKIP_FILE_10%, which skips a file only once the count of erroring rows exceeds ten percent of the rows in that file, leaving files with a low error rate loaded.
- A. This is correct.
SKIP_FILE_<num>%sets a percentage error-rate threshold, and the file is only skipped once the proportion of erroring rows in it crosses that percentage, which is exactly the threshold-based skip behavior the team wants. - B. Plain
SKIP_FILEskips the entire file after the very first error, with no threshold at all, so it would discard files that only have one bad row among thousands of good ones — too aggressive for this requirement. - C.
CONTINUEnever skips a file regardless of how many rows in it fail, so a file that is almost entirely corrupt would still have its clean rows loaded with no file-level cutoff, which does not give the team a skip threshold. - D.
ABORT_STATEMENTterminates the whole multi-file COPY operation at the first error anywhere, so it never reaches a per-file error-rate evaluation and cannot express a percentage threshold.
Checkpoint 5 of 9· Exam question
Which statement correctly describes the default ON_ERROR behavior when no ON_ERROR option is specified?
Correct answer: A — Bulk loading with COPY INTO defaults to ABORT_STATEMENT, while continuous loading through Snowpipe defaults to SKIP_FILE for the same unspecified option.
- A. This is correct. Bulk
COPY INTOstatements default toABORT_STATEMENT, stopping the whole file's load on the first error, while Snowpipe defaults toSKIP_FILE, skipping only the offending file so continuous ingestion keeps flowing. - B. This reverses the actual defaults. Bulk loads do not silently continue past errors by default, and Snowpipe does not abort an entire continuous pipeline over one bad file; the real defaults are the opposite of what this option states.
- C. Bulk
COPY INTOdoes not default toSKIP_FILE; its unspecified default isABORT_STATEMENT, so this option is only half right for Snowpipe and wrong for bulk loading, meaning the two mechanisms do not share the same default. - D. Snowpipe does not default to
ABORT_STATEMENT; a continuous pipeline that aborted on every bad file would be impractical, which is why Snowpipe's unspecified default isSKIP_FILEinstead.
3.Seeing every error, not just the first
FIRST_ERROR_MESSAGE names one error per file. If you fix that one and reload, you often hit the next. Two tools list every error. Which one to use depends on whether the load has already run.
Before loading, or when re-checking files that failed, run the same COPY with VALIDATION_MODE = RETURN_ALL_ERRORS. The statement validates the files and returns their errors without loading anything. The rejected records can then be unloaded to a stage file and fixed in the source data:
COPY INTO mytable
FROM @mystage/myfile.csv.gz
VALIDATION_MODE=RETURN_ALL_ERRORS;
SET qid=last_query_id();
COPY INTO @mystage/errors/load_errors.txt FROM (SELECT rejected_record FROM TABLE(result_scan($qid)));After a load has run, the VALIDATE table function returns every error from that COPY. Pass a query ID, or '_last' for the last load in the current session. It has two blind spots. It returns nothing for a COPY that ran with ON_ERROR = ABORT_STATEMENT, so it pairs with CONTINUE or a skip setting. It also fails if the COPY transformed data with a SELECT, or if the load metadata has expired. VALIDATION_MODE likewise rejects COPY statements that transform data or use MATCH_BY_COLUMN_NAME.
SELECT * FROM TABLE(VALIDATE(t1, JOB_ID => '_last'));Pipes have their own version of this. VALIDATE_PIPE_LOAD takes a pipe name and a start time and returns the line, column and rejected record of each error in files the pipe failed to load. It errors on pipes that transform semi-structured data such as JSON or Parquet. When neither validation path works, use the copy history: the FIRST_ERROR_* columns locate the first problem and ERROR_COUNT shows how many rows are bad.
Checkpoint 6 of 9· Check yourself
After a bulk COPY INTO with no ON_ERROR option stops on a malformed row, you want the full list of errors in the staged file so you can fix them all in one pass. Which approach gives you that list?
VALIDATION_MODE = RETURN_ALL_ERRORS checks the file and returns every error without loading anything. VALIDATE returns nothing for a COPY that ran with the default ABORT_STATEMENT, and an aborted COPY leaves no copy history. Even when history exists, it shows only the first error. VALIDATE_PIPE_LOAD works only for pipes.
“Execute a COPY statement with the VALIDATION_MODE copy option set to RETURN_ALL_ERRORS. In the statement, reference the set of files you had attempted to load.”Source: docs.snowflake.com
4.Files skipped, ignored or loaded twice
A file that "didn't load" without any error was usually skipped on purpose, because of load metadata (Load metadata and the 64-day deduplication window). Old files are the typical case. Suppose a file's LAST_MODIFIED date and its last load into the table are both more than 64 days old. COPY can no longer tell whether it was loaded, and to prevent an accidental reload it skips the file by default.
Two options get such files loaded, and the choice depends on how much you trust the metadata. LOAD_UNCERTAIN_FILES = TRUE still checks whatever load metadata exists to avoid duplicates, but also tries the files whose metadata has expired. FORCE = TRUE ignores load metadata completely and reloads everything that matches. That makes it a common cause of duplicated rows. Use it only when you have removed the earlier copy of the data or actually want it twice.
Pipes also ignore files that look already loaded. If a corrected file is staged again under the same name, Snowpipe may skip it. The sign is a single copy-history row for that file whose LAST_LOAD_TIME is earlier than the time you staged it again. If you record Snowpipe events at DEBUG level, the ignored file shows a file_lifecycle event with a SKIPPED state.
Checkpoint 7 of 9· Check yourself
You fix a bad row in orders_0412.csv and upload it again to the pipe's stage under the same name. An hour later the corrected rows still aren't in the table. COPY_HISTORY shows one row for that file, with status Loaded and a LAST_LOAD_TIME from before your re-upload. What happened?
Pipes skip files that look already loaded. A single history row with a load time earlier than the re-upload means Snowpipe ignored the new copy. A rejected file would have its own Load failed row. A truncate removes the earlier loads from the history, so it can't explain a row from before the re-upload.
“the results show only one row for that file, with a LAST_LOAD_TIME earlier than when you staged it again, Snowpipe ignored the new copy”Source: docs.snowflake.com
5.When a pipe loads nothing or a stage breaks
When an auto-ingest pipe (Snowpipe (auto-ingest vs REST API)) loads nothing, copy history shows no errors, because no file was ever attempted. The cause is in one of three places: the event notifications from cloud storage, the pipe itself, or the files. SYSTEM$PIPE_STATUS returns a JSON object that tells you which one.
SELECT SYSTEM$PIPE_STATUS('mydb.myschema.orders_pipe');| Field | What an unexpected value means |
|---|---|
| executionState | Not RUNNING: the pipe usually isn't loading. If pendingFileCount grows while PAUSED, resume the pipe |
| lastReceivedMessageTimestamp | Missing or older than your newest files: event notifications aren't reaching Snowflake |
| lastForwardedMessageTimestamp | Messages received but not forwarded: the notifications aren't for new files in the location the pipe watches |
| channelErrorMessage | GCS or Azure only: the Pub/Sub subscription or storage queue, or the notification integration, is misconfigured |
| error | The pipe's COPY statement failed to compile, for example because of a missing object or privilege |
Sometimes copy history is missing a file you expected. There are four possible reasons. The file may still be queued (check oldestPendingFilePath). The pipe may never have been notified, or the file sits outside the pipe's path. The pipe may have been dropped or recreated, in which case query the Account Usage COPY_HISTORY view. Or the table may have been truncated since the load.
A stage can break without any change to the stage itself. Error 003139, Integration '{0}' associated with the stage '{1}' cannot be found, appears after someone runs CREATE OR REPLACE STORAGE INTEGRATION. A stage links to its storage integration through a hidden ID, not the name. Replacing the integration drops it and creates a new one with a different ID. Even though the name is the same, run ALTER STAGE stage_name SET STORAGE_INTEGRATION = storage_integration_name on every stage that used it.
Checkpoint 8 of 9· Match them up
An auto-ingest pipe has stopped loading, and copy history shows no errors. Match each SYSTEM$PIPE_STATUS reading to what it tells you.
Tap a term, then the definition that fits it.
Each field points to a different part of the chain: notifications arriving, notifications being forwarded to this pipe, the pipe's own state and its COPY statement. An auto-ingest pipe that loads nothing never attempts a file, so these fields show where the chain broke.
“Snowpipe forwards a notification to a pipe only when the notification is for a new file in the location that the pipe watches.”Source: docs.snowflake.com
Checkpoint 9 of 9· Check yourself
Overnight, an admin ran CREATE OR REPLACE STORAGE INTEGRATION s3_int with exactly the same settings as before. This morning, every COPY from the external stage ext_orders fails with error 003139: the integration associated with the stage cannot be found. Nobody changed the stage. What fixes it?
A stage refers to its storage integration by a hidden ID, not by its name. CREATE OR REPLACE drops the integration and creates a new one with a new ID, so each stage that used it must be linked again with ALTER STAGE ... SET STORAGE_INTEGRATION. Granting privileges, refreshing a pipe or waiting for notifications doesn't change the broken link.
“A stage links to a storage integration using a hidden ID rather than the name of the storage integration.”Source: docs.snowflake.com
Sources
(8)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“The FIRST_ERROR_MESSAGE column provides a reason when an attempt partially loaded or failed.”
↩︎ Finding failed files in COPY_HISTORY and LOAD_HISTORY“CURRENT_TIMESTAMP is evaluated when the load operation is compiled in cloud services rather than when the record is inserted into the table”
↩︎ Finding failed files in COPY_HISTORY and LOAD_HISTORY“No data is loaded when this copy option is specified.”
↩︎ Choosing the ON_ERROR setting that fits the failure“This happens when the storage integration object has been recreated (using CREATE OR REPLACE STORAGE INTEGRATION).”
↩︎ When a pipe loads nothing or a stage breaks“A stage links to a storage integration using a hidden ID rather than the name of the storage integration.”
↩︎ When a pipe loads nothing or a stage breaks“The STATUS column indicates whether a particular set of files was loaded, partially loaded, or failed to load.”
↩︎ Key concept“Execute a COPY statement with the VALIDATION_MODE copy option set to RETURN_ALL_ERRORS. In the statement, reference the set of files you had attempted to load.”
↩︎ Checkpoint - 2.
“The function returns load activity for both COPY INTO <table> statements and continuous data loading using Snowpipe.”
↩︎ Finding failed files in COPY_HISTORY and LOAD_HISTORY“Dropping or recreating a pipe object removes the historical data for Snowpipe data loads using the pipe.”
↩︎ Finding failed files in COPY_HISTORY and LOAD_HISTORY - 3.
“This view returns an upper limit of 10,000 rows.”
↩︎ Finding failed files in COPY_HISTORY and LOAD_HISTORY“This view does not return the history of data loaded using Snowpipe.”
↩︎ Exam trap 2“No record is added if the transaction is rolled back”
↩︎ Prediction - 4.
“within the last 365 days (1 year)”
↩︎ Finding failed files in COPY_HISTORY and LOAD_HISTORY - 5.
“We recommend that you search for the failures in QUERY_HISTORY.”
↩︎ Finding failed files in COPY_HISTORY and LOAD_HISTORY“The difference between the ROWS_PARSED and ROWS_LOADED column values represents the number of rows that include detected errors.”
↩︎ Choosing the ON_ERROR setting that fits the failure“Skip a file when the percentage of error rows found in the file exceeds the specified percentage.”
↩︎ Choosing the ON_ERROR setting that fits the failure“The SKIP_FILE action buffers an entire file whether errors are found or not.”
↩︎ Choosing the ON_ERROR setting that fits the failure“Default:Bulk loading using COPY:ABORT_STATEMENTSnowpipe:SKIP_FILE”
↩︎ Exam trap 1 - 6.
“By default (ON_ERROR = SKIP_FILE), Snowpipe doesn’t load a file that contains errors, and the file has the Load failed status.”
↩︎ Choosing the ON_ERROR setting that fits the failure“The function returns details such as the line and column where each error occurred and the rejected record”
↩︎ Seeing every error, not just the first“and ERROR_COUNT shows how many rows have errors.”
↩︎ Seeing every error, not just the first“an ignored file has a file_lifecycle event with a SKIPPED state”
↩︎ Files skipped, ignored or loaded twice“the event notifications from your cloud storage service, the pipe itself, or the files”
↩︎ When a pipe loads nothing or a stage breaks“The table function covers the last 14 days. For older loads, query the COPY_HISTORY view in the Account Usage schema.”
↩︎ When a pipe loads nothing or a stage breaks“the results show only one row for that file, with a LAST_LOAD_TIME earlier than when you staged it again, Snowpipe ignored the new copy”
↩︎ Checkpoint“Snowpipe forwards a notification to a pipe only when the notification is for a new file in the location that the pipe watches.”
↩︎ Checkpoint - 7.
“returns all the errors encountered during the load, rather than just the first error.”
↩︎ Seeing every error, not just the first“SELECT statements are used to transform data during a COPY INTO <table> operation.”
↩︎ Seeing every error, not just the first“The validation returns no results for COPY statements that specify ON_ERROR = ABORT_STATEMENT (default value).”
↩︎ Exam trap 3 - 8.
“In this case, to prevent accidental reload, the command skips the file by default.”
↩︎ Files skipped, ignored or loaded twice“To load files whose metadata has expired, set the LOAD_UNCERTAIN_FILES copy option to true.”
↩︎ Files skipped, ignored or loaded twice“Note that this option reloads files, potentially duplicating data in a table.”
↩︎ Files skipped, ignored or loaded twice