LOAD_HISTORY Function

Description: The LOAD_HISTORY function is used to view the COPY job file import history of a table, with a retention period of 7 days. When executing, the Pipe uses load_history to avoid re-importing existing files, ensuring data uniqueness.

Syntax:

load_history('schema_name.table_name')

Parameters:

  • schema_name.table_name: Specifies the table for which to view the import history, in the format schema_name.table_name.

Return Fields:

FieldTypeDescription
file_pathSTRINGPath of the imported file
last_copy_timeTIMESTAMPTime of the most recent import operation
file_sizeBIGINTFile size (bytes)
statusSTRINGImport status, LOADED indicates success, LOAD_FAILED indicates failure
first_error_messageSTRINGFirst error message encountered, NULL on success

Examples:

Example 1: View all import history for a table

SELECT * FROM load_history('myschema.mytable');

Example 2: View only successfully imported records

SELECT file_path, last_copy_time, file_size FROM load_history('myschema.mytable') WHERE status = 'LOADED';

Example 3: View failed import records and error messages

SELECT file_path, last_copy_time, first_error_message FROM load_history('myschema.mytable') WHERE status = 'LOAD_FAILED';

Example 4: Filter by time range

SELECT * FROM load_history('myschema.mytable') WHERE last_copy_time > '2026-05-01' ORDER BY last_copy_time DESC;