Categories:

Information Schema , Table functions

VALIDATE_PIPE_LOAD

This table function can be used to validate data files processed by Snowpipe within a specified time range. The function returns details about any errors encountered during an attempted data load into Snowflake tables.

Note

This function returns errors only for files in the pipe’s load history, which covers the last 14 days. For a time range before the last 14 days, the function returns no results. Recreating a pipe removes its load history, so the function also returns no results for files that the pipe processed before you recreated it.

Syntax

VALIDATE_PIPE_LOAD(
      PIPE_NAME => '<string>'
       , START_TIME => <constant_expr>
      [, END_TIME => <constant_expr> ] )

Arguments

PIPE_NAME => string

A string specifying a pipe. The function returns results for the specified pipe only.

START_TIME => constant_expr

Timestamp (in TIMESTAMP_LTZ format), within the last 14 days, marking the start of the time range for retrieving error events.

Optional:

END_TIME => constant_expr

Timestamp (in TIMESTAMP_LTZ format), within the last 14 days, marking the end of the time range for retrieving error events.

Usage notes

  • Returns results only for the pipe owner (i.e. the role with the OWNERSHIP privilege on the pipe) or a role with the following minimum permissions:

    PrivilegeObjectNotes
    MONITORPipeAlternatively, the global MONITOR EXECUTION privilege is supported.
    USAGEStage in the pipe definitionExternal stages only
    READStage in the pipe definitionInternal stages only
    SELECTTable in the pipe definition
    INSERTTable in the pipe definition
    SQL operations on schema objects also require USAGE or any other privilege on the database and schema that contain the object.
  • When calling an Information Schema table function, the session must have an INFORMATION_SCHEMA schema in use or the function name must be fully-qualified. For more details, see Snowflake Information Schema.

  • If Snowpipe encountered no errors while processing data files within the specified time range, the function returns no results.

  • If the COPY statement in the pipe definition transforms semi-structured data, such as JSON or Parquet data, during the load (that is, a COPY transformation), or if it uses MATCH_BY_COLUMN_NAME, the function returns a user error. The function supports pipes that transform CSV data.

  • The function doesn’t return rows that violate CHECK constraints.

  • To record every row that a pipe rejects, including rows from pipes that transform data and rows that violate CHECK constraints, turn on error logging for the pipe’s target table and use ON_ERROR = CONTINUE in the pipe. To change the ON_ERROR value of an existing pipe, recreate the pipe. Error logging supports CSV, JSON, and Parquet files. For more information, see Error logging for COPY INTO and Snowpipe.

Output

The function returns the following columns:

Column NameData TypeDescription
ERRORTEXTError in the source file. The function returns a row for each error in the file.
FILETEXTName of the source file where the error was encountered.
LINENUMBERNumber of the line in the source file where the error was encountered.
CHARACTERNUMBERPosition of the character where the error was encountered.
BYTE_OFFSETNUMBERByte offset to the character where the error was encountered.
CATEGORYTEXTCategory of the operation when the error was produced.
CODENUMBERID for the error message displayed in the ERROR column.
SQL_STATENUMBERSQL state code.
COLUMN_NAMETEXTName and order of the column that contained the error.
ROW_NUMBERNUMBERNumber of the row in the source file where the error was encountered.
ROW_START_LINENUMBERNumber of the first line of the row where the error was encountered.
REJECTED_RECORDTEXTRecord that contained the error.

Examples

Validate any loads for the mypipe pipe within the previous hour:

select * from table(validate_pipe_load(
  pipe_name=>'MY_DB.PUBLIC.MYPIPE',
  start_time=>dateadd(hour, -1, current_timestamp())));