FRESHNESS

functionsupportedGovernance (policies, tags, data quality)Enterprise+

docs.snowflake.com ↗

Data metric functions

Returns how much time in seconds has elapsed since a table was last modified. When a column argument is specified, the time period is calculated by comparing the current run of the function with the maximum value of a timestamp column. If the scheduled time to run the function is different from the time it actually ran, then the scheduled time is used for the comparison. When no column is specified, the time period is calculated by comparing the current run of the function with the last time a DML command acted on the table. If the scheduled time to run the function is different from the time it actually ran, then the scheduled time is used for the comparison. This topic provides the syntax for calling the function directly. To learn how to associate the function with a table or view so it runs at regular intervals, see Associate a DMF. Data Quality Monitoring requires Enterprise Edition. To inquire about upgrading, please contact Snowflake Support.

Syntax

supportedpartialnot supportednot scored

SNOWFLAKE.CORE.FRESHNESS( [ <query> ] )

Parameters

NameRequiredDescription
queryrequiredIf specified, the query must project a single timestamp column. If you don’t want to specify a column, you must associate the function with a table rather than call it directly.

Returns

The function returns a scalar value with a NUMBER data type.

Usage notes

Allowed data types

The column projected by the query must have one of the following data types: - DATE - TIMESTAMP_LTZ - TIMESTAMP_TZ TIMESTAMP_NTZ columns aren’t supported. To measure the freshness of a TIMESTAMP_NTZ column, create a custom DMF that calls DATA_METRIC_SCHEDULED_TIME. For an example, see Measure the freshness of a TIMESTAMP_NTZ column.

Example

Associate the function with the table t1 to determine how long it’s been since the last DML operation on the table: Call the function directly to determine the freshness of the data, 300 seconds or 5 minutes, in the table by measuring the TIMESTAMP column: