View results of a data metric function

This topic describes the different ways you can access the results of a data metric function (DMF).

Note

If you want to find the rows that failed a data quality check, see Remediation of data quality issues.

Managing access to the DMF results

You have three options to access the results of a scheduled DMF:

Depending on how you want to manage access to the DMF results, grant the following system application roles to another account-level role:

Application role

Notes

DATA_QUALITY_MONITORING_ADMIN

Can use options 1, 2, and 3.

A role that is granted this application role can grant the DATA_QUALITY_MONITORING_VIEWER and DATA_QUALITY_MONITORING_LOOKUP application roles to other roles.

A user that is granted the ACCOUNTADMIN role can grant the DATA_QUALITY_MONITORING_ADMIN application role to other roles.

DATA_QUALITY_MONITORING_VIEWER

Options 2 and 3.

DATA_QUALITY_MONITORING_LOOKUP

Option 3 only.

For example, use the GRANT APPLICATION ROLE command to grant the DATA_QUALITY_MONITORING_VIEWER system application role to the analyst custom role:

USE ROLE ACCOUNTADMIN;
GRANT APPLICATION ROLE SNOWFLAKE.DATA_QUALITY_MONITORING_VIEWER TO ROLE analyst;
Copy

Use the REVOKE APPLICATION ROLE command to revoke the system application role from an account role.

Tip

Additionally, if you want to manage access to the results of system DMFs, grant the SNOWFLAKE.DATA_METRIC_USER database role to the account role that can access the results. For more information, see GRANT DATABASE ROLE.

Option 1: Query the dedicated event table

This option gives you access to the raw data, and you have more freedom to post-process the data using derived objects, such as creating views, table functions, or stored procedures based on how you want to analyze the results. Additionally, if you create these derived objects, you can selectively grant access on these objects to different roles. For example, a data engineer can access the stored procedures to maintain the approach to obtain the results, and a data analyst can access the view to analyze the results.

The event table is named SNOWFLAKE.LOCAL.DATA_QUALITY_MONITORING_RESULTS_RAW.

For information about the event table columns, see Event table columns.

For a representative example to query the event table, see the logging and tracing tutorial.

Option 2: Query the DATA_QUALITY_MONITORING_RESULTS view

This option enables you to query the DATA_QUALITY_MONITORING_RESULTS view, which flattens the raw data in the event table to enable easier access to the DMF results. Additionally, this option is best when data post-processing is not needed and when you don’t want to grant access to the raw data.

The view exists in the LOCAL schema in the shared SNOWFLAKE database: SNOWFLAKE.LOCAL.DATA_QUALITY_MONITORING_RESULTS.

For information, see the DATA_QUALITY_MONITORING_RESULTS view.

Note

The SNOWFLAKE.GOVERNANCE_VIEWER database role does not have access to query the DATA_QUALITY_MONITORING_RESULTS view.

Option 3: Call the DATA_QUALITY_MONITORING_RESULTS table function

This option enables you to call the DATA_QUALITY_MONITORING_RESULTS table function to view the DMF results. The function returns the same columns as the DATA_QUALITY_MONITORING_RESULTS view. However, you can only specify a single table when calling the function. This option is best when you want to limit data metric function results to a single table and not provide access to the measurements of other tables or the event table.

In addition to the SNOWFLAKE.DATA_QUALITY_MONITORING_LOOKUP application role, the role used to call the DATA_QUALITY_MONITORING_RESULTS table function also needs the following privileges:

  • OWNERSHIP or SELECT on the table.

  • OWNERSHIP or USAGE on the DMF.