SECONDS_SINCE_ROW_COUNT_CHANGE

functionnot supportedGovernance (policies, tags, data quality)Enterprise+

docs.snowflake.com ↗

Data metric functions

Returns the number of seconds since the last committed DML operation that changed the number of rows in the associated table. Use this function to detect a stalled load: a table in which rows have stopped being added or removed. Data Quality Monitoring requires Enterprise Edition. To inquire about upgrading, please contact Snowflake Support.

Syntax

To associate the function with a table

ALTER TABLE <table>
  ADD DATA METRIC FUNCTION SNOWFLAKE.CORE.SECONDS_SINCE_ROW_COUNT_CHANGE ON ()

Returns

The function returns a NUMBER value: the number of seconds between the commit of the most recent DML operation that changed the number of rows in the table and the time the function is evaluated. The value is never negative. The following table shows which DML operations reset the value: If no DML operation has changed the number of rows since the table was created, the value is the time since the table was created. If Snowflake doesn’t find a table version that changed the number of rows, the value is the time since the oldest table version it reads. This happens when only operations that don’t change the number of rows, such as UPDATE, have run for longer than the table’s retained version history, or when more such operations have run than Snowflake reads. In this case, the value is a lower bound: the number of rows last changed at least that many seconds ago. The function doesn’t indicate whether the value is a lower bound.

Usage notes

Example

Set an hourly schedule for table raw.sales.orders, then associate the function with the table and define an expectation that is violated when the number of rows hasn’t changed for more than one day: