Schema:

ACCOUNT_USAGE

LOAD_HISTORY view

This Account Usage view enables you to retrieve the history of data loaded into tables using the COPY INTO <table> command within the last 365 days (1 year). The view displays one row for each file loaded.

Note

This view does not return the history of data loaded using Snowpipe. For this historical information, query the COPY_HISTORY view instead.

Columns

Column NameData TypeDescription
TABLE_IDNUMBERInternal/system-generated identifier for the target table
TABLE_NAMEVARCHARName of target table
SCHEMA_IDNUMBERInternal/system-generated identifier for the schema of the target table
SCHEMA_NAMEVARCHARSchema of target table
CATALOG_IDNUMBERInternal/system-generated identifier for the database of the target table
CATALOG_NAMEVARCHARDatabase of target table
FILE_NAMEVARCHARName of source file
LAST_LOAD_TIMETIMESTAMP_LTZDate and time (in the UTC time zone) of the load record
STATUSVARCHARStatus: LOADED, LOAD FAILED, or PARTIALLY LOADED
ROW_COUNTNUMBERNumber of rows loaded from the source file
ROW_PARSEDNUMBERNumber of rows parsed from the source file
FIRST_ERROR_MESSAGEVARCHARFirst error of the source file
FIRST_ERROR_LINE_NUMBERNUMBERLine number of the first error
FIRST_ERROR_CHARACTER_POSITIONNUMBERPosition of the first error character
FIRST_ERROR_COL_NAMEVARCHARColumn name of the first error
ERROR_COUNTNUMBERNumber of error rows in the source file
ERROR_LIMITNUMBERIf the number of error reach this limit, then abort

Usage notes

  • In most cases, latency for the view may be up to 90 minutes. The latency for a given table’s load history in the view may be up to 2 days if both of the following conditions are true:
    • Fewer than 32 DML statements have been added to the given table since it was last updated in LOAD_HISTORY.
    • Fewer than 100 rows have been added to the given table since it was last updated in LOAD_HISTORY.
  • The view only includes COPY INTO commands that executed to completion, with or without errors. No record is added if the transaction is rolled back, for example, or if the ON*ERROR = ABORT_STATEMENT copy option is included in the COPY INTO *<table>_ statement and a detected error in a data file aborts the load operation.
  • When including a WHERE clause that references the LAST_LOAD_TIME column, you can specify any day of the week. For example, April 1, 2016 was a Friday; however, specifying Sunday instead does not affect the query results:
    WHERE last_load_time > 'Sun, 01 Apr 2016 16:00:00 -0800'
  • After the replication of load history, the LOAD_HISTORY Account Usage view shows the history only after the latest truncate operation on the target table. This is different from the view without replication, which shows a complete data loading history.

Examples

Retrieve records for the 10 most recent COPY INTO commands executed:

SELECT file_name, last_load_time FROM snowflake.account_usage.load_history
  ORDER BY last_load_time DESC
  LIMIT 10;