DYNAMIC_TABLE_REFRESH_HISTORY

functionsupportedTables, views, streams, sequences

docs.snowflake.com ↗

Information SchemaTable functions

This table function returns information about each refresh (completed and running) of dynamic tables. This table function returns all refreshes that are in progress as well as all refreshes that have a DATA_TIMESTAMP within 7 days of the current time.

Syntax

supportedpartialnot supportednot scored

DYNAMIC_TABLE_REFRESH_HISTORY(
  [ DATA_TIMESTAMP_START => <constant_expr> ]
  [ , DATA_TIMESTAMP_END => <constant_expr> ]
  [ , RESULT_LIMIT => <integer> ]
  [ , NAME => '<string>' ]
  [ , NAME_PREFIX => '<string>' ]
  [ , ERROR_ONLY => { TRUE | FALSE } ]
)

Parameters

NameRequiredDescription
DATA_TIMESTAMP_START => constant_expr , DATA_TIMESTAMP_END => constant_exprrequiredTime range (in TIMESTAMP_LTZ format) during which the refreshes occurred. If neither a start version nor an end version is specified, the default range will be the past day. If an end version is not specified, CURRENT_TIMESTAMP is used as the end of the range. If a start version is not specified, the range starts 1 day prior to the start of DATE_TIMESTAMP_END.
RESULT_LIMIT => integerrequiredA number specifying the maximum number of rows returned by the function. If the number of matching rows is greater than this limit, the refreshes that finished most recently (and those that are still running) are returned, up to the specified limit. To apply a filter on the results, also specify a large enough RESULT_LIMIT limit value for the filter to be applied on all dynamic tables. Range: 1 to 10000 Default: 100.
NAME => stringrequiredThe name of a dynamic table. Names must be single-quoted and are case insensitive. You can specify the unqualified name (dynamic_table_name), the partially qualified name (schema_name.dynamic_table_name), or the fully qualified name (database_name.schema_name.dynamic_table_name). For more information on object name resolution, refer to Object name resolution. The function returns the refreshes for this table.
NAME_PREFIX => stringrequiredA prefix for dynamic tables. Name prefixes must be single-quoted and are case insensitive. The function returns refreshes for tables with names that start with this prefix. You can use this argument to return the refreshes for dynamic tables in a specific database or schema.
ERROR_ONLY => TRUE | FALSErequiredWhen set to TRUE, this function returns only refreshes that failed or were cancelled.

Usage notes

Output

The function returns the following columns. To view these columns, you must use a role with the MONITOR privilege or a privilege that includes it, such as OPERATE. For more information about dynamic table privileges, see Grant MONITOR to view metadata. Column Name | Data Type | Description NAME | TEXT | Name of the dynamic table. SCHEMA_NAME | TEXT | Name of the schema that contains the dynamic table. DATABASE_NAME | TEXT | Name of the database that contains the dynamic table. STATE | TEXT | Status of the refresh for the dynamic table. The status can be one of the following: SCHEDULED: refresh scheduled, but not yet executed. EXECUTING: refresh in progress. SUCCEEDED: refresh completed successfully. FAILED: refresh failed during execution. CANCELLED: refresh was canceled before execution. UPSTREAM_FAILED: refresh not performed due to an upstream failed refresh. UPSTREAM_DATA_QUALITY_VIOLATION: refresh not performed because a data quality check on an upstream object detected an issue. For more information, see Skip downstream dynamic table refreshes when a data quality check fails. SKIPPED: refresh not performed because an upstream dynamic table refresh was skipped or the scheduler deferred the refresh to maximize time within target lag. STATE_CODE | TEXT | Code representing the current state of the refresh. STATE_MESSAGE | TEXT | Description of the current state of the refresh. QUERY_ID | TEXT | ID of the SQL statement that produced the results for the dynamic table. DATA_TIMESTAMP | TIMESTAMP_LTZ | Transactional timestamp when the refresh was evaluated. (This might be slightly before the actual time of the refresh.) All data, in base objects, that arrived before this timestamp is currently included in the dynamic table. REFRESH_START_TIME | TIMESTAMP_LTZ | Time when the refresh job started. REFRESH_END_TIME | TIMESTAMP_LTZ | Time when the refresh completed. COMPLETION_TARGET | TIMESTAMP_LTZ | Time by which this refresh should complete to keep lag under the TARGET_LAG parameter for the dynamic table. This is equal to the DATA_TIMESTAMP of the last refresh + TARGET_LAG. QUALIFIED_NAME | TEXT | Fully qualified name of the dynamic table as it appears in the graph of dynamic tables. You can use this to join the output with the output of the DYNAMIC_TABLE_GRAPH_HISTORY function. LAST_COMPLETED_DEPENDENCY | OBJECT | Contains the following properties: qualified_name: The qualified name of the latest dependency to become available. data_timestamp: The refresh version of that dependency. STATISTICS | OBJECT | Contains the following properties: numInsertedRows: The number of inserted rows. numDeletedRows: The number of rows that were deleted. numCopiedRows: The number of rows that were copied unchanged. numAddedPartitions: The number of added partitions. numRemovedPartitions : The number of removed partitions. queuedTimeMs: The time (in milliseconds) spent in the queued state. compilationTimeMs: The time (in milliseconds) spent compiling the refresh query. executionTimeMs: The time (in milliseconds) spent executing the refresh query. dataQualityGateTimeMs: The time (in milliseconds) that an upstream data quality gate held the refresh while it waited for a data quality result. For a refresh that the gate skipped, this is the only property. For successful refreshes, this column includes both the row/partition statistics and the time distribution information. For example:Copy code { "numAddedPartitions": 1, "numCopiedRows": 0, "numDeletedRows": 25, "numInsertedRows": 36, "numRemovedPartitions": 1, "queuedTimeMs": 123, "compilationTimeMs": 456, "executionTimeMs": 789 } For failed refreshes, this column is populated with the time distribution information only. For example:Copy code { "queuedTimeMs": 123, "compilationTimeMs": 456, "executionTimeMs": 789 } Note Because a JSON object is an unordered set of keys and values, the order of properties in the output may vary from the examples above. For example, if an UPDATE statement updates 1 row in a partition with 10 rows, the row/partition metrics show 1 row inserted, 1 deleted, and 9 copied. Additionally, 1 partition is removed and 1 partition added. REFRESH_ACTION | TEXT | One of: NO_DATA - no new data in base tables, so the refresh is skipped, regardless of refresh mode. The refresh uses Cloud Services compute to detect that nothing changed and doesn’t consume virtual warehouse credits. Doesn’t apply to the initial refresh of newly created dynamic tables regardless of whether or not the base tables have data. REINITIALIZE - base table changed, source table of a cloned dynamic table was refreshed during clone, or an ADAPTIVE dynamic table chose to reinitialize because processing changes incrementally would be more expensive. FULL - Full refresh, because dynamic table contains query elements that are not incrementalizable (see SHOW DYNAMIC TABLE refresh_mode_reason) or because full refresh was cheaper than incremental refresh. INCREMENTAL - normal incremental refresh. CUSTOM_INCREMENTAL - refresh executed the user-defined DML in the REFRESH USING clause. REINIT_REASON | TEXT | When REFRESH_ACTION is REINITIALIZE, describes why the dynamic table was reinitialized, such as base table changes or adaptive refresh mode decisions. NULL for other refresh actions. REFRESH_TRIGGER | TEXT | One of: SCHEDULED - normal background refresh to meet target lag or downstream target lag. MANUAL - user/task used ALTER DYNAMIC TABLE <name> REFRESH CREATION - refresh performed during the creation DDL statement, triggered by the creation of the dynamic table or any consumer dynamic tables. TARGET_LAG_SEC | NUMBER | Describes the target lag value for the dynamic tables at the time the refresh occurred. GRAPH_HISTORY_VALID_FROM | TIMESTAMP_NTZ | Encodes the VALID_FROM timestamp of the DYNAMIC_TABLE_GRAPH_HISTORY table function when the refresh occurred to clarify which version of a dynamic table a specific refresh corresponds to. This value can also be NULL if the corresponding dynamic table hasn’t been created. INPUTS_WITH_CHANGED_DATA | ARRAY of OBJECTs | Each OBJECT represents a table, view, or dynamic table that serves as the input to this dynamic table and had changed data during this refresh. Each OBJECT consists of: name (TEXT): The fully qualified name. kind (TEXT): The type of input (TABLE, DYNAMIC_TABLE, or VIEW). statistics (OBJECT): Present for TABLE and DYNAMIC_TABLE inputs. Contains: numRegisteredRows: The number of rows added to this input. numUnregisteredRows: The number of rows removed from this input. numAddedPartitions: The number of added partitions. numRemovedPartitions: The number of removed partitions. baseTableStatisticsAgg (OBJECT): Present for VIEW inputs instead of statistics. Contains the same sub-properties. Because views have no DML of their own, this sums the DML statistics from the view’s underlying base tables. If multiple VIEW inputs share an underlying base table, that base table contributes to each view’s statistics independently. For example:Copy code [ { "name": "MY_DB.MY_SCHEMA.MY_TABLE", "kind": "TABLE", "statistics": { "numRegisteredRows": 9, "numUnregisteredRows": 0, "numAddedPartitions": 2, "numRemovedPartitions": 0 } }, { "name": "MY_DB.MY_SCHEMA.MY_VIEW", "kind": "VIEW", "baseTableStatisticsAgg": { "numRegisteredRows": 4, "numUnregisteredRows": 0, "numAddedPartitions": 1, "numRemovedPartitions": 0 } } ] Note Because a JSON object is an unordered set of keys and values, the order of properties in the output may vary from the example above. NULL if: REFRESH_ACTION is NO_DATA (no input changed). The refresh failed before it could identify which inputs had changed. For failed refreshes, the column is populated with any inputs that could be identified as changed before the failure occurred.