ROW_COUNT_DIFFERENCE

functionsupportedGovernance (policies, tags, data quality)Enterprise+

docs.snowflake.com ↗

Data metric functions

Returns the number of rows in the associated table minus the number of rows in a reference table. Use this function to check that a table, such as a copy or the output of a pipeline, has the same number of rows as the table it is loaded from. You associate the function with the table you want to check and specify the reference table as a reference-table argument. 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.ROW_COUNT_DIFFERENCE
    ON ( <column>, TABLE( <ref_table>( <ref_column> ) ) )

Parameters

NameRequiredDescription
columnrequiredSpecifies one column in the associated table. The function uses the column only to identify the table, and ignores its values.
TABLE(ref_table(ref_column))requiredSpecifies the reference table and one of its columns: ref_table: The fully qualified name of the reference table (for example, my_db.my_schema.my_table). ref_column: One column in the reference table. The function uses the column only to identify the table, and ignores its values.

Returns

The function returns a NUMBER value: the number of rows in the associated table minus the number of rows in the reference table. - A value of 0 means that both tables have the same number of rows. - A negative value means that the associated table has fewer rows than the reference table. - A positive value means that the associated table has more rows than the reference table. The function counts every row, including rows where the specified columns contain NULL.

Usage notes

Allowed data types

The columns specified in the column and ref_column arguments can have any data type. The two columns don’t need to have the same data type.