VALIDATE
functionsupportedData loading & unloadingValidates the files loaded in a past execution of the COPY INTO <table> command and returns the errors encountered during the load, rather than just the first error.
Syntax
supportedpartialnot supportednot scored
VALIDATE( [<namespace>.]<table_name> , JOB_ID => { '<query_id>' | '_last' } )
Parameters
| Name | Required | Description |
|---|---|---|
[namespace.]table_name | required | Specifies the fully-qualified name of the table that was the target of the load. Namespace is the database and/or schema in which the table resides, in the form of database_name.schema_name or schema_name. It is optional if a database and schema are currently in use within the user session; otherwise, it is required. |
JOB_ID => query_id | _last | required | The ID for the COPY INTO <table> command to be validated: The ID can be obtained from the Query ID column in the Query History page in Snowsight. The specified query ID must have been for the specified target table. If _last is specified instead of query_id, the function validates the last load executed during the current session, regardless of the specified target table. |
Usage notes
- The validation returns no results for COPY statements that specify ON_ERROR = ABORT_STATEMENT (default value).
- Validation fails if: SELECT statements are used to transform data during a COPY INTO <table> operation.
- The current user does not have access to table_name.
- The current user is not the user who executed query_id and does not have access control privileges on this user.
- The copy history metadata has expired. For more information, refer to Load metadata.
- If new files have been added to the stage used by query_id since the load was executed, the new files added are ignored during the validation.
- If files have been removed from the stage used by query_id since the load was executed, the files removed are reported as missing.
- The function doesn’t return rows that violate CHECK constraints.
- To keep a record of rejected rows that you can query later, including rows from loads that transform data and rows that violate CHECK constraints, turn on error logging for the target table and load the files with ON_ERROR = CONTINUE. Error logging supports CSV, JSON, and Parquet files. For more information, see Error logging for COPY INTO and Snowpipe.
Output
The function returns one row for each error, with the following columns: Column Name | Data Type | Description ERROR | TEXT | Error encountered in the source file. FILE | TEXT | Name of the source file where the error was encountered. LINE | NUMBER | Number of the line in the source file where the error was encountered. CHARACTER | NUMBER | Position of the character where the error was encountered. BYTE_OFFSET | NUMBER | Byte offset to the character where the error was encountered. CATEGORY | TEXT | Category of the operation when the error was produced. CODE | NUMBER | ID for the error message displayed in the ERROR column. SQL_STATE | TEXT | SQL state code. COLUMN_NAME | TEXT | Name and order of the column that contained the error. ROW_NUMBER | NUMBER | Number of the row in the source file where the error was encountered. ROW_START_LINE | NUMBER | Number of the first line of the row where the error was encountered. REJECTED_RECORD | TEXT | Record that contained the error.