SYSTEM$DATA_METRIC_SCAN

functionsupportedGovernance (policies, tags, data quality)Enterprise+

docs.snowflake.com ↗

System functionsTable functions

Returns the rows identified by a data quality metric as containing data that fails a data quality check. For example, if you use the NULL_COUNT data metric function as an argument, the function returns the rows in the table that contain a NULL value in a specific column. Data Quality Monitoring requires Enterprise Edition. To inquire about upgrading, please contact Snowflake Support.

Syntax

supportedpartialnot supportednot scored

SYSTEM$DATA_METRIC_SCAN(
  REF_ENTITY_NAME  => '<object>'
  , METRIC_NAME  => '<data_metric_function>'
  , ARGUMENT_NAME => '<column> [ , <column> ... ]'
  [ , ARGUMENT_EXPRESSION => '<boolean-expression>' ]
  [ , AT_TIMESTAMP => '<timestamp>' ]
  [ , WITHIN_GROUP_VALUES => '<json_object>' ]
)

Parameters

NameRequiredDescription
REF_ENTITY_NAME => 'object'requiredName of the table or view on which the specified data metric function will run. The function returns rows from this object.
METRIC_NAME => 'data_metric_function'requiredName of the system data metric that you want to run to evaluate the specified table or view. Only the following system functions are supported: SNOWFLAKE.CORE.ACCEPTED_VALUES SNOWFLAKE.CORE.ACCEPTED_VALUES_PERCENT SNOWFLAKE.CORE.BLANK_COUNT SNOWFLAKE.CORE.BLANK_PERCENT SNOWFLAKE.CORE.DUPLICATE_COUNT SNOWFLAKE.CORE.NULL_COUNT SNOWFLAKE.CORE.NULL_PERCENT
ARGUMENT_NAME => 'column [ , column ... ]'requiredName of the columns in the specified table or view that are being passed as arguments to the specified data metric function.
ARGUMENT_EXPRESSION => 'boolean-expression'optionalRequired if the specified data metric function is ACCEPTED_VALUES or ACCEPTED_VALUES_PERCENT. Disallowed for all other DMFs. Specifies a Boolean expression used to evaluate whether a record passes or fails the ACCEPTED_VALUES or ACCEPTED_VALUES_PERCENT data quality check. The SYSTEM$DATA_METRIC_SCAN function returns records that do not match the Boolean expression. The expression can include the following operators and functions: Comparison operators Logical operators [ NOT ] LIKE [ NOT ] IN IS [ NOT ] NULL The column in the Boolean expression must be the same column specified in the ARGUMENT_NAME argument. If the ACCEPTED_VALUES or ACCEPTED_VALUES_PERCENT DMF is associated with the object specified by REF_ENTITY_NAME, the SYSTEM$DATA_METRIC_SCAN function ignores the Boolean expression that was specified when the DMF was associated with the object.
AT_TIMESTAMP => 'timestamp'optionalTimestamp string specifying the historical snapshot to scan. The function uses Time Travel to evaluate the specified DMF against the table or view data at that time. It does not retrieve stored evaluation results. The requested time must be within the Time Travel retention period of the queried tables and must not precede their creation. The string is converted using TO_TIMESTAMP. Its format must match the TIMESTAMP_INPUT_FORMAT session parameter, which defaults to AUTO. The resulting timestamp type depends on the TIMESTAMP_TYPE_MAPPING session parameter: With the default TIMESTAMP_NTZ mapping, any timezone offset in the string is discarded. Time Travel interprets the resulting clock time as UTC. Supply a UTC timestamp string. For example, use the format YYYY-MM-DD HH24:MI:SS.FF3 when TIMESTAMP_INPUT_FORMAT is AUTO. With TIMESTAMP_LTZ or TIMESTAMP_TZ mapping, an explicit timezone offset is honored. If the string has no offset, the TIMEZONE session parameter determines the timezone. To scan data from a past DMF measurement, use MEASUREMENT_TIME from DATA_QUALITY_MONITORING_RESULTS. For an example, see Calling the SYSTEM$DATA_METRIC_SCAN function.
WITHIN_GROUP_VALUES => 'json_object'optionalFor an association created with a WITHIN GROUP clause, a JSON object that maps grouping column names to the specific group values to scan. For example: '{"REGION": "US", "PRODUCT_CATEGORY": "Electronics"}'. If you omit this argument, the scan returns all rows regardless of group. Only string and numeric values are supported in the JSON object. For more information, see Apply data quality checks by group.

Returns

Rows from the specified table or view.

Usage notes

Access control privileges

Executing this function requires the following privileges: - SELECT on the specified table. - USAGE on the specified data metric function.