Auto data quality in Knowledge Catalog (formerly Dataplex Universal Catalog) lets you validate your BigQuery, Iceberg REST Catalog, SAP Business Data Cloud Delta Lake, and Apache Hive tables against defined rules. You can automate scans, measure quality scores, and log alerts when records don't meet your requirements to help maintain the integrity of data production pipelines. To identify statistical characteristics of your tables and generate rule recommendations, see About data profiling.
When to use auto data quality
The following are some common use cases:
- Automate data validation across pipelines: automatically validate data arriving in your BigQuery, Iceberg REST Catalog, SAP Business Data Cloud Delta Lake, and Apache Hive tables against predefined or custom rules to prevent corrupt data from reaching downstream analytics.
- Establish proactive monitoring and alerting: trigger automated alerts in Cloud Logging when data fails to meet specified quality thresholds to help your data engineering team resolve anomalies quickly.
- Scale governance with reusable templates: share standard business rules, such as null checks or uniqueness expectations, across multiple data scans by using rule templates to reduce duplicate effort.
- Manage data quality policies as code: define and deploy the quality rules using code to enforce standardized data governance and simplify version control across enterprise data assets.
- Monitor data integrity trends: review overall and dimension-level data quality scores, such as completeness and validity, over time to demonstrate compliance with internal data SLAs.
Conceptual model
A data quality scan is a type of Knowledge Catalog data
scan
that validates your data against defined rules. Auto data quality supports only
BigQuery tables (including Cloud Storage data accessed through
BigQuery external tables), Iceberg REST Catalog tables, SAP
Business Data Cloud Delta Lake tables, and Apache Hive tables. To measure the
quality of a table by using auto data quality, you create a DataScan object of
type data quality. Each scan runs on a single supported table and uses
resources in a Google tenant
project, so you don't need to set
up your own infrastructure.
To create and use a data quality scan, follow these steps:
- Define data quality rules.
- Configure rule execution.
- Analyze data quality scan results.
- Set up monitoring and alerting.
- Troubleshoot data quality failures.
You can manage data quality rules and deployments as code and use integrated Knowledge Catalog monitoring, troubleshooting, and Logging alerting across your scans.
Rule definition
Data quality rules associated with a data quality scan define data expectations. You can create data quality rules in the following ways:
- Use rule recommendations generated by a Knowledge Catalog data profile scan.
- Use the built-in rules or system rule templates.
- Create custom SQL rules.
- Reuse data quality rules (see #reuse-rules).
Built-in rules
Knowledge Catalog supports the following categories of built-in rules:
- Row-level
For row-level category rules, the expectation is applied against each data row. Each row independently passes or fails the condition. For example,
column_A_value < 1.Row-level checks require you to specify a passing threshold. When the percentage of rows passing the rule falls below the threshold value, the rule fails.
- Aggregate
For aggregate rules, the expectation is applied against a single value aggregated across the entire data. For example,
Avg(someCol) >= 10. To pass, the check must evaluate to the Booleantrue. Aggregate rules don't provide an independent pass or fail count for each row.
For both of the rule categories, you can set the following parameters:
- The column to which the rule applies
- A dimension
The following table lists the supported row-level and aggregate rule types:
| Rule type (Name in Google Cloud console) |
Row-level or aggregate rule | Description | Supported column types | Rule-specific parameters |
|---|---|---|---|---|
RangeExpectation(Range Check) |
Row-level | Determines whether values fall within a specified minimum and maximum range. | All numeric, date, and timestamp type columns. | Required:
|
NonNullExpectation(Null check) |
Row-level | Validate that column values are not NULL. | All supported column types. | Required:
|
SetExpectation(Set check) |
Row-level | Determines whether column values match a specified set of values. | All supported column types, except Record and Struct. |
Required:
|
RegexExpectation(Regular expression check) |
Row-level | Validates values against a specified regular expression. | String | Required:
|
Uniqueness(Uniqueness Check) |
Aggregate | Determines whether all values in a column are unique. | All supported column types, except Record and Struct. |
Required:
|
StatisticRangeExpectation(Statistic check) |
Aggregate | Determines whether the specified statistical measure matches the range expectation. | All supported numeric column types. | Required:
|
Supported custom SQL rule types
SQL rules provide flexibility to expand the validation with custom logic, as described in the following table.
| Rule type | Row-level or aggregate rule | Description | Supported column types | Rule-specific parameters | Example |
|---|---|---|---|---|---|
| Row condition | Row-level | Specify an expectation for every row by defining a SQL
expression in a WHERE clause. The SQL expression should
evaluate to true (pass) or false (fail)
per row.Knowledge Catalog computes the percentage of rows that pass this expectation and compares this value against the passing threshold percentage to determine the success or failure of the rule. The expression can include a reference to another table, for example, to create referential integrity checks. |
All columns | Required:
|
grossWeight <= netWeight |
| Table condition (aggregate SQL expression) |
Aggregate | These rules are executed once per table. Provide a SQL expression that
evaluates to boolean true (pass) or false (fail).The SQL expression can include a reference to another table using expression subqueries. |
All columns | Required:
|
Simple aggregate example:avg(price) > 100Using an expression subquery to compare values across a different table: (SELECT COUNT(*) FROM `example_project.example_dataset.different-table`) < COUNT(*) |
| SQL assertion | Aggregate | An assertion rule uses a data quality query to find rows that fail
one or more conditions specified in the query. Provide a SQL statement
that is evaluated to return rows that match the invalid state. If the
query returns any rows, the rule fails. Omit the trailing semicolon from the SQL statement. The SQL statement can include a reference to another table using expression subqueries. |
All columns | Required:
|
Simple aggregate example to make sure that discount_pct
is not greater than 100:SELECT * FROM example_project.example_dataset.table WHERE discount_pct > 100Using an expression subquery to compare values across a different table: SELECT * FROM `example_project.example_dataset.different-table` WHERE gross_weight > (SELECT avg(gross_weight) FROM `example_project.example_dataset.different-table`)
|
For example rules, see auto data quality sample rules.
For supported SQL functions, see the GoogleSQL reference.
Reuse data quality rules
You can reuse Knowledge Catalog data quality rules to share complex or standardized business rule definitions across multiple data quality rules by using rule templates. For example, you can create a rule template for an email validation or for foreign key validation between two tables, and then reuse those templates across your data scans.
Reusing data quality rules includes the following components:
- Data quality rule templates: create custom rule templates to store
complex or standardized business rule definitions that can be shared across
multiple data quality rules. Create a
data-quality-rule-templateentry and add adata-quality-rule-templateaspect to it to define the template logic. - Data rules as metadata: declare data quality rules as aspects in
Knowledge Catalog on entries such as
BigQuery tables or business glossary terms. Use the
data-rulesaspect type to attach these rules to entries. - System rule templates: use predefined system rule templates for commonly used rules.
To browse predefined templates, see System rule templates list.
Dimensions
A dimension is a category used to measure a specific aspect of data quality, such as completeness or validity. Associating rules with dimensions lets you group scan results for monitoring and alerting. For example, instead of tracking individual rule failures in isolation, you can monitor an overall completeness score across a table.
You must associate every data quality rule with a dimension. Knowledge Catalog provides the following predefined dimensions:
- Freshness
- Measures when the data was last updated or whether it's recent enough to be
useful. Freshness checks evaluate time intervals or timestamps to verify
that data pipelines deliver data on schedule. For example, you can use a
custom SQL rule or the
freshness_expectationsystem rule template to verify that the latest timestamp in an events table is within the last 24 hours. - Volume
- Measures the quantity or amount of data, verifying that the expected volume of
records is present. Volume checks evaluate dataset size using metrics such
as total row count to detect missing data batches, incomplete ingestion
runs, or unexpected truncations. For example, you can use a table condition
to verify that a daily ingestion table contains at least 100,000 rows
(
COUNT(*) >= 100000), or compare the row count of a destination table against a source table. - Completeness
- Assesses whether all required data fields contain values without unexpected
missing or null entries. Completeness checks evaluate whether attributes
within records are populated. For example, you can use a null check
(
NonNullExpectation) to verify that mandatory columns such ascustomer_idororder_datedon't contain null values. - Validity
- Evaluates whether data conforms to predefined technical standards, formats,
schemas, or valid value ranges. For example, you can use a regular
expression check (
RegexExpectation) to verify that email addresses follow a valid format, or a range check (RangeExpectation) to verify that a discount percentage is between 0 and 100. You can also use a set check (SetExpectation) to verify that order status values match an allowed list, such as('PENDING', 'SHIPPED', 'DELIVERED'). - Consistency
- Evaluates whether data values and relationships agree without contradiction
across multiple tables, columns, or systems. For example, you can use a
custom SQL rule to verify referential integrity between an
orderstable and acustomerstable, or verify thatgross_weight >= net_weightwithin each row. You can also verify that total sales revenue reported in a daily summary table equals the sum of line items in a transactions table. - Accuracy
- Reflects the correctness of the data and whether it truthfully represents real-world entities or authoritative reference values. You can evaluate accuracy by cross-referencing records with authoritative external data sources or checking real-world business rules, such as verifying that a transaction timestamp isn't in the future.
- Uniqueness
- Measures whether data values are distinct and free from unintended duplicate
records. For example, you can use a uniqueness check
(
UniquenessExpectation) to verify that a primary key or identifier column such astransaction_idcontains only unique values.
Distinguish between similar dimensions
When you define data quality rules, some dimensions might seem similar. Use the following guidelines to select the appropriate dimension:
- Completeness versus volume:
- Completeness evaluates whether fields within records are populated, such as checking whether a column contains null or missing values.
- Volume evaluates the overall quantity of records in the dataset, such as checking the total row count for a table or partition to verify that all expected rows were loaded.
- Completeness versus validity:
- Completeness evaluates whether a required value is present (not
null), such as verifying that an
emailcolumn is populated. - Validity evaluates whether a present value conforms to an expected
format, range, or set, such as verifying that a non-null
emailvalue matches a valid email pattern rather than a placeholder string such as'N/A'.
- Completeness evaluates whether a required value is present (not
null), such as verifying that an
- Validity versus accuracy:
- Validity evaluates whether data conforms to structural rules, syntax, acceptable ranges, or formats, such as checking whether a phone number contains 10 digits.
- Accuracy evaluates whether data reflects real-world truth or authoritative reality, such as checking whether that phone number belongs to the customer. Data can be valid without being accurate.
- Consistency versus accuracy:
- Consistency evaluates whether data matches across different systems, tables, or records, such as verifying that a customer's status is the same in both the billing and customer service databases.
- Accuracy evaluates whether data matches the real-world state. Data can be consistent across multiple systems while remaining inaccurate if both systems contain the wrong value.
Typed input in rules
All value parameters are passed as string values to the API. Knowledge Catalog requires inputs to follow the BigQuery specified format.
Binary-typed parameters can be passed as a base64-encoded string.
| Type | Supported formats | Examples |
|---|---|---|
| Binary | Base64 encoded value | YXBwbGU= |
| Timestamp | YYYY-[M]M-[D]D[( |T)[H]H:[M]M:[S]S[.F]] [time_zone] OR YYYY-[M]M-[D]D[( |T)[H]H:[M]M:[S]S[.F]][time_zone_offset] |
2014-09-27 12:30:00.45-08 |
| Date | YYYY-M[M]-D[D] | 2014-09-27 |
| Time | [H]H:[M]M:[S]S[.DDDDDD] | 12:30:00.45 |
| DateTime | YYYY-[M]M-[D]D [[H]H:[M]M:[S]S[.DDDDDD]] | 2014-09-27 12:30:00.45 |
Data reference parameter
When you create a custom SQL rule, you can refer to a data source table and all
of its precondition filters by using the data reference parameter ${data()} in
the rule, instead of explicitly mentioning the source table and its filters.
Knowledge Catalog interprets the parameter as a reference to the source
table and its filters. Examples of precondition filters include row
filters, sampling
percents, and incremental filters.
For example, suppose that you have a data source table called
my_project_id.dim_dataset.dim_currency. You want to run an incremental data
quality scan that scans only on new daily data. A row filter that filters for
today's entries, transaction_timestamp >= current_date(), is applied on the
table.
A custom SQL rule to find rows with discount_pct for today looks like this:
discount_pct IN (SELECT discount_pct FROM my_project_id.dim_dataset.dim_currency WHERE transaction_timestamp >= current_date())
If you use the data reference parameter, you can simplify the rule. Replace the
mention of the table and its precondition filters with the ${data()}
parameter:
discount_pct IN (SELECT discount_pct FROM ${data()})
Knowledge Catalog interprets the ${data()} parameter as a reference to
the data source table with today's entries,
my_project_id.dim_dataset.dim_currency WHERE transaction_timestamp >=
current_date(). In this example, the data reference parameter refers only to
the incremental data.
The ${data()} parameter is case sensitive.
When you use an alias within a subquery to refer to columns in the source table,
either use the data reference parameter to refer to the source table, or omit
the table reference. Don't refer to the columns in the source table by using a
direct table reference in the WHERE clause.
Recommended:
Use the data reference parameter to refer to the source table:
discount_pct IN ( SELECT discount_pct FROM `my_project_id.dim_dataset.dim_currency` AS temp-table WHERE temp-table.transaction_timestamp = ${data()}.timestamp )Omit the table reference:
discount_pct IN ( SELECT discount_pct FROM `another_project.another_dataset.another_table` AS temp-table WHERE temp-table.transaction_timestamp = timestamp
Not recommended:
Don't use a direct table reference to refer to columns in the source table:
discount_pct IN ( SELECT discount_pct FROM `my_project_id.dim_dataset.dim_currency` AS temp-table WHERE temp-table.transaction_timestamp = `my_project_id.dim_dataset.dim_currency`.timestamp )
Valid use of different tables:
You can use a direct table reference when comparing columns from a different table:
discount_pct IN ( SELECT discount_pct FROM `my_project_id.dim_dataset.dim_currency` AS temp-table WHERE temp-table.transaction_timestamp = `another_project.another_dataset.another_table`.timestamp )
Debug queries
When you create a rule, you can optionally include a debug query to run alongside the rule. A debug query is a SQL statement that returns up to 10 scalar values. These values can help diagnose the cause if the rule fails. You can add at most one debug query per rule, and it must not exceed 1024 characters in length.
Consider the following SQL assertion rule on the
example_project.example_dataset.table table that checks whether the average
revenue per item exceeds 100:
SELECT
*
FROM
`example_project.example_dataset.table`
WHERE
SUM(revenue) / COUNT(DISTINCT item_id) > 100
If the previous rule fails, you can view metrics such as total revenue, number of distinct items, and average revenue per item to help diagnose the issue. The following debug query returns these metrics:
SELECT
SUM(revenue),
COUNT(DISTINCT item_id),
SUM(revenue) / COUNT(DISTINCT item_id)
FROM `example_project.example_dataset.table`
Rule execution
You can schedule data quality scans to run at a specific interval, or you can run a scan on demand.
Execution identity
By default, Knowledge Catalog uses a centralized service agent
(service-PROJECT_NUMBER@gcp-sa-dataplex.iam.gserviceaccount.com) to run data quality scans.
You can override this default execution identity by specifying a custom service account or by using your own End-User Credentials (EUC). This provides several benefits:
- Principle of least privilege: grant only the exact Identity and Access Management (IAM) permissions required for specific data quality tasks to a dedicated service account, minimizing overprovisioned access.
- Fine-grained access control: scope permissions to specific resources, allowing integration with row-level and column-level access policies in BigQuery.
- Improved auditability: assign custom service accounts or user credentials to specific scans, making tracking and logging of activities much clearer in audit logs.
- Billing unification: when you use a custom execution identity, the processing and storage charges are centralized directly under BigQuery (bypassing Knowledge Catalog Premium SKUs). This lets you take advantage of BigQuery enterprise discounts and slot commitments.
For instructions on how to configure a custom execution identity, see Configure execution identity.
Networking requirements
To run a scan, you must enable Private Google Access on the VPC subnet that you use for the scan. If you don't specify a subnet, make sure your default subnet has Private Google Access enabled.
When you run a data quality scan, Knowledge Catalog creates a job. If a job is misconfigured or running longer than expected, you can cancel the job.
As part of the specification of a data quality scan, you can specify the scope of a job to be one of the following:
- Full Table
- Each job validates the entire table.
- Incremental
- Each job validates incremental data. To determine increments, provide a
DateorTimestampcolumn in the table that can be used as a marker. Typically, this is the column on which the table is partitioned.
Filter data
You can filter data to be scanned for data quality by using a row filter. Creating a row filter lets you focus on data within a specific time period or specific segment, such as a certain region. Using filters can reduce the run time and cost. For example, you can filter out data with a timestamp before a certain date.
Sample data
You can specify a percentage of records from your data to sample for running a data quality scan. Running data quality scans on a smaller sample of data can reduce the run time and the cost relative to querying the entire dataset.
Filter rules
When you run a data quality scan, you can use
AIP-160 filter syntax to selectively execute
specific rules. Knowledge Catalog performs filtering on
the metadata of the rules defined in the scan or rules attached to the catalog
entry through the data-rules aspect.
Filter syntax
The filter syntax follows AIP-160 guidelines. You can use standard AIP-160
operators (for example, =, !=, >, <, =~) and combine multiple
conditions using AND or OR.
When you use an AIP-160 filter string, do the following:
- In the Google Cloud console: enter the filter directly using AIP-160
syntax (for example,
name = "critical_check"). - In an API call: the filter string is often a value within another JSON
string literal. This requires escaping double quotes within the AIP-160
string. For example,
"filter": "name = \"critical_check\"".
Filterable fields
You can filter on most fields available in the rule definition:
name: the display name of the rule.dimension: the data quality dimension (for example,VALIDITY).column: the name of the column the rule applies to.threshold: the passing threshold for the rule.ignore_null: a boolean value. Whentrue,NULLrows are considered passing.attributes: custom key-value pairs assigned to the rule.
The following examples show common filter patterns. Numeric and boolean values aren't quoted.
Filter by name
- Match exactly:
name = "critical_check" - Match a pattern:
name =~ "temp_.*"
Filter by dimension
- Match a specific dimension:
dimension = "COMPLETENESS" - Match multiple dimensions:
dimension = "VALIDITY" OR dimension = "ACCURACY"
Filter by column and threshold
- Match a specific column:
column = "user_id" - Match a threshold:
threshold > 0.95 - Match a range:
threshold >= 0.8 AND threshold < 0.9
Filter by ignore_null
- Match boolean value:
ignore_null = true
Filter by custom attributes
- Check for key presence:
attributes:environment - Match key and value:
attributes.environment = "prod" - Match using regular expressions:
attributes.tag =~ "prio-.*" - Match combinations:
attributes.environment = "prod" AND attributes.criticality = "high"
Data quality scan results
The results of your data quality scans are available in Knowledge Catalog and BigQuery. You can also review and analyze the scan results using the following methods:
Export results to BigQuery
You can export the scan results to a BigQuery table for further analysis. To customize reporting, you can connect the BigQuery table data to a Looker dashboard. You can build an aggregated report using the same results table across multiple scans.
Publish results as Knowledge Catalog metadata
You can publish the data quality scan results as Knowledge Catalog metadata. The latest results are saved to the Knowledge Catalog entry that represents the source table, under the
data-quality-scorecardsystem aspect type. You can view the results on the source table's BigQuery and Knowledge Catalog pages in the Google Cloud console, on the Data quality tab. You can also retrieve the results using the API.For more information about Knowledge Catalog metadata, see About metadata management in Knowledge Catalog.
Review data quality scores
Each scan result provides data quality scores that indicate the percentage of rules that passed. The scores are reported at the overall job level, the column level, if the rule is evaluated against a column, and the dimension level. Use the data quality scores to normalize data quality across tables or columns, track trends, and identify data that doesn't meet quality requirements.
For more information, see View the data quality scan results.
Monitoring and alerting
You can monitor and get alerts about data quality scans using the following methods:
Set alerts in Cloud Logging
You can monitor the data quality jobs using the
data_scananddata_quality_scan_rule_resultlogs in the Logs Explorer.For each data quality job, the
data_scanlog with thedata_scan_typefield set toDATA_QUALITYcontains the following information:- Data source used for the data scan.
- Job execution details, such as creation time, start time, end time, and job state.
- Result of the data quality job: pass or fail.
- Dimension level pass or fail.
Each successful job contains a
data_quality_scan_rule_resultlog with the following detailed information about each rule in that job:- Configuration information, such as rule name, rule type, evaluation type, and dimension.
- Result information, such as pass or failure, total row count, passing row count, null row count, and evaluated row count.
The information in the logs is available through the API and Google Cloud console. You can use this information to set up alerts. For more information, see Set alerts in Logging.
Send email notification reports
You can send email notification reports to alert people about the status and results of a data quality job. Notification reports are available for the following scenarios:
- The data quality score is lower than a specified target score
- The job failed
- The job finished
You configure notification reports when you create a data quality scan.
Monitor DCU compute costs in Cloud Billing
Data quality scan serverless compute doesn't emit time-series metrics to Cloud Monitoring. To track and attribute Data Quality DCU costs by project, scan ID, or table, query Cloud Billing export in BigQuery using
goog-dataplex-datascan-*system labels. For more information, see Monitor and attribute Knowledge Catalog DCU costs with Cloud Billing export.
Troubleshoot data quality failures
When a rule execution fails, Knowledge Catalog provides a query to retrieve the failed records. Run this query to see the records that didn't match your rule. For more information, see Troubleshoot a data quality failure.
Limitations
- Rule recommendations aren't supported in the gcloud CLI.
- In the Google Cloud console, the choice of dimensions is fixed to one of the seven predefined dimensions.
- The number of rules per data quality scan is limited to 1000.
- Data quality scores that are reported at the column level are supported only in the API.
- You can run data quality rules only on BigQuery tables (including Cloud Storage data accessed through BigQuery external tables), Iceberg REST Catalog tables, SAP Business Data Cloud Delta Lake tables, and Apache Hive tables. Other data sources, such as Cloud SQL and third-party databases, aren't supported.
Pricing
- For more information about pricing, see Knowledge Catalog pricing.
- To track and attribute Data Quality scan DCU usage and costs using Cloud Billing export to BigQuery, see Monitor and attribute Knowledge Catalog DCU costs with Cloud Billing export.
What's next
- Learn how to use auto data quality.
- Learn about reusing data quality rules, or follow guides to create and manage rule templates and apply data quality rules and run scans.
- Learn how to manage your data quality rules as code.
- Follow a tutorial to build a policy-as-code data quality workflow.
- Learn about the available Terraform resources for data profiling. See the following:
- Dataplex data scan resource in the Terraform registry.
- The Dataplex data scan resource documentation on GitHub, which supports YAML-based rule configuration.
- Learn about data profiling.
- Learn how to use data profiling.