CertSafari
    Snowflake SnowPro Advanced: Data Engineer (DEA-C02)· Lessons

    Domain 1 · Lesson 3/22

    Diagnosing failed COPY and Snowpipe file loads

    Troubleshoot data ingestion.

    15 min read
    4% of exam
    8 sources
    Published 20 Oct 2026
    Docs as of 18 Oct 2026

    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.

    Per-file outcome for the last 24 hours of loads into one tablesql
    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.

    Where to look for a file's load outcome
    SourceCoversWindowWatch out for
    INFORMATION_SCHEMA.COPY_HISTORY (table function)COPY INTO and SnowpipeLast 14 daysOmits loads by a pipe that was dropped or recreated
    INFORMATION_SCHEMA.LOAD_HISTORY (view)COPY INTO onlyLast 14 daysNo Snowpipe loads; upper limit of 10,000 rows
    ACCOUNT_USAGE.LOAD_HISTORY (view)COPY INTO onlyLast 365 daysNo Snowpipe loads
    ACCOUNT_USAGE.COPY_HISTORY (view)COPY INTO and SnowpipeBeyond 14 daysUse 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;

    Sources12345

    2.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.

    ON_ERROR values and what each does with a bad row
    ValueEffectWhen it wins
    ABORT_STATEMENT (bulk default)Stops the load if any error is found in a data fileAll-or-nothing loads where partial data is worse than none
    CONTINUELoads the good rows of every file; returns at most one error message per fileKeep loading past malformed rows and count rejects afterwards
    SKIP_FILE (Snowpipe default)Skips any file containing an error; buffers every file, so it is slowerFiles that must load whole or not at all
    SKIP_FILE_num, e.g. SKIP_FILE_10Skips a file when its error rows equal or exceed the numberTolerate 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 percentageDrop 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?

    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?

    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?

    Checkpoint 5 of 9· Exam question

    Which statement correctly describes the default ON_ERROR behavior when no ON_ERROR option is specified?

    Sources561

    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:

    Validate a failed file, then unload its rejected records for repairsql
    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.

    All errors from the most recent COPY in this sessionsql
    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?

    Sources76

    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?

    Sources86

    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.

    Check a pipe's state and notification timestampssql
    SELECT SYSTEM$PIPE_STATUS('mydb.myschema.orders_pipe');
    Reading SYSTEM$PIPE_STATUS fields
    FieldWhat an unexpected value means
    executionStateNot RUNNING: the pipe usually isn't loading. If pendingFileCount grows while PAUSED, resume the pipe
    lastReceivedMessageTimestampMissing or older than your newest files: event notifications aren't reaching Snowflake
    lastForwardedMessageTimestampMessages received but not forwarded: the notifications aren't for new files in the location the pipe watches
    channelErrorMessageGCS or Azure only: the Pub/Sub subscription or storage queue, or the notification integration, is misconfigured
    errorThe 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.

    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?

    Sources61

    Sources

    (8)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 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. 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. 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. 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
    5. 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
    6. 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
    7. 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

    Continue to part 2 of 2

    Snowpipe Streaming errors: channels, offsets and error tables

    Spotted a mistake, or was something unclear? Tell us.