Knowledge Catalog (formerly Dataplex Universal Catalog) lets you reuse data quality rules by defining standardized validation logic once and applying it across multiple BigQuery tables and scans. Centralizing these checks helps you reduce duplicate SQL maintenance, build data trust, and enforce consistent governance standards across your data estate.
This document is for data stewards, data engineers, and analysts who want to understand how rule libraries, rule templates, and catalog-based rules work together. To author custom SQL templates, see Create and manage rule templates. To attach rules to tables or business glossary terms and run scans, see Apply data quality rules and run scans. For an overview of data quality scans and built-in rules, see Auto data quality overview.
Why reuse data quality rules
As your organization scales to hundreds of BigQuery tables, writing separate validation checks for every scan creates drift and maintenance overhead. Reusing rules separates rule authoring from scan execution so teams can share verified validation logic consistently.
The following table contrasts managing rules per scan with reusing rules through Knowledge Catalog:
| Aspect | Per-scan rules | Reusing rules |
|---|---|---|
| Rule definition | Duplicated SQL or built-in checks defined separately in each scan. | Standardized system or custom templates stored once in a rule library. |
| Maintenance effort | High. Updating business logic requires editing every scan definition. | Low. Updating a template or glossary rule applies to subsequent scan runs. |
| Ownership | Data engineers author and maintain both business logic and scan schedules. | Governance teams author verified templates; engineering teams apply them to scans. |
| Discoverability | Rules live inside individual scan configurations. | Templates and attached rules are searchable catalog metadata. |
Use cases
Teams reuse data quality rules to solve the following enterprise governance and engineering challenges:
- Standardize enterprise business checks: a central data governance team defines verified custom templates—such as standardized email, account ID, or foreign key checks—in a shared rule library. Data engineering teams across business units reference those templates instead of writing duplicate SQL, helping support consistent compliance and reducing maintenance overhead.
- Automate governance through glossary inheritance: a compliance steward attaches validation rules to approved business glossary terms, such as a Customer Email term. When engineers link BigQuery table columns to that term, those columns automatically inherit the required checks without manual per-table configuration.
- Bootstrap quality monitoring quickly: data engineers setting up a pipeline use predefined system rule templates for common checks, such as schema matching, freshness, and null expectations. Teams can then validate tables immediately without authoring custom SQL.
- Discover and reuse verified rule sets: data analysts and engineers use semantic search in Knowledge Catalog to find existing templates and table-level rules, such as financial reconciliation checks. They can then import or reference those rules for related datasets.
- Separate governance from pipeline operations: central governance teams own and audit SQL validation logic in custom rule libraries, while platform and pipeline engineers focus on scheduling scans, filtering rules by environment, and monitoring results.
Core concepts
Reusing data quality rules builds on the Knowledge Catalog metadata model of entry groups, entries, and aspects. Understanding these components from outer containers to inner mechanics helps you design a scalable governance hierarchy.
Rule library
A rule library is a Knowledge Catalog entry group that stores and organizes related data quality rule templates within a project and location.
- Storage model: represented as a standard entry group labeled with
goog-dataplex-entry-group-type: rule_library. - Location scope: confined to a specific region, such as
us-central1, orglobal. You can't change a rule library's location after you create it. - Example: a
finance-rule-libraryentry group inus-central1that holds all revenue and ledger validation templates for the finance domain.
To create a rule library, see Create a rule library.
Rule template
A rule template is a parameterized SQL validation definition stored as a
catalog entry inside a rule library so you can reuse it across scans and
tables. Each template uses the data-quality-rule-template entry type and
stores its SQL query, dimension, input parameters, and capabilities in the
data-quality-rule-template aspect.
Knowledge Catalog supports two categories of rule templates: system rule templates and custom rule templates.
System rule templates
System rule templates are predefined, Google-managed rule templates for common row-level and aggregate validations, such as null checks, regular expression matching, freshness, and schema expectations.
- Location and scope: stored globally in the
dataplex-templatesproject under therule-libraryentry group, so you can reference them from scans and catalog entries in any region. - Resource name format:
projects/dataplex-templates/locations/global/entryGroups/rule-library/entries/TEMPLATE_ID(for example,projects/dataplex-templates/locations/global/entryGroups/rule-library/entries/non_null_expectation). - Reference: for the full catalog of available templates, see System rule templates list.
To browse system rule templates in the Google Cloud console or REST API, see Browse system rule templates.
Custom rule templates
Custom rule templates are organization-authored templates stored in your own rule libraries to capture domain-specific or cross-table validation logic.
- Mutability: modifying a custom template's SQL logic changes subsequent scan runs that reference it.
- Scoping constraint: a scan or catalog entry can reference a custom
template only if the template resides in the same region or in
global. - Example: a
foreign-key-checktemplate that acceptsreference_tableandreference_columnparameters to verify referential integrity across tables.
To author and maintain custom templates, see Create and manage rule templates.
Data rules as metadata
Data rules as metadata are concrete validation rule instances attached
directly to catalog entries using the dataplex-types.global.data-rules system
aspect type.
- Attachment targets: you can attach
data-rulesaspects to BigQuery table entries at the table or column path, and to business glossary term entries. - Decoupled lifecycle: attaching rules as metadata makes them searchable and auditable independently of individual scan schedules.
- Example: attaching a
valid-emailrule referencing a shared regular expression template to thecustomer_emailcolumn of acustomerstable entry.
To attach rules to catalog entries, see Attach rules to catalog entries.
Glossary-based rule inheritance
Glossary-based rule inheritance automatically propagates validation rules from a business glossary term to every BigQuery table or column linked to that term.
- Mechanism: when you link a glossary term to a BigQuery
column through an
EntryLink, the column inherits all rules defined in the term'sdata-rulesaspect. - Dynamic resolution: catalog-based scans resolve inherited rules at runtime, so adding or modifying a rule on the glossary term automatically applies to all linked columns on the next scan run.
- Example: linking a Transaction Amount glossary term—with a non-null
and positive-range rule attached—to
amountcolumns across 20 sales tables.
To attach rules to glossary terms, see Attach rules to a business glossary term.
Catalog-based scans and rule filtering
A catalog-based scan is a data quality scan configured with
enableCatalogBasedRules set to true, or with Create with entry based
rule in the Google Cloud console. Instead of hardcoding rules inside the
scan specification, the scan dynamically reads all rules attached directly to
the target table entry and inherited from linked glossary terms at execution
time.
You can pair template-reference scans or catalog-based scans with an
AIP-160 filter
to run a subset of rules for specific environments or schedules. For example,
filter with attributes.environment = "prod" or dimension = "VALIDITY".
Workflow to reuse data quality rules
The end-to-end lifecycle for reusing data quality rules connects template authoring, asset binding, and scan execution across three stages.
The following diagram shows how system and custom rule templates flow through direct scan references or catalog metadata into a BigQuery validation scan:
The workflow follows three stages:
- Define or choose templates: data stewards or engineers select predefined
system rule templates from the global
rule-libraryor author custom SQL templates in a custom rule library. For procedural steps, see Create and manage rule templates. Bind rules to data assets: teams choose one of two binding paths depending on their governance model:
- Path A (direct scan reference): reference a template directly in a
data quality scan's
ruleslist usingtemplateReferenceand provide parameter values for that table. - Path B (catalog metadata): attach
data-rulesaspects to BigQuery table entries or business glossary terms so that rules propagate automatically to linked columns. Then configure a scan withenableCatalogBasedRulesenabled.
For procedural steps for both paths, see Apply data quality rules and run scans.
- Path A (direct scan reference): reference a template directly in a
data quality scan's
Run and evaluate the scan: when the scan runs, Knowledge Catalog gathers the applicable rules, applies any AIP-160 rule filter, and substitutes system and custom parameters into each template's SQL query. The service then runs the validation query in BigQuery using the configured execution service account. Scan results report dimension-level scores, failing row counts, and the resolved SQL (
resolvedSql) for debugging.
Rule options and binding models
Before creating templates or scans, choose the rule definition type and binding model that match your team's governance and operational needs.
Rule definition types
The following table compares built-in rules, system rule templates, and custom rule templates:
| Feature | Built-in rules | System rule templates | Custom rule templates |
|---|---|---|---|
| Source | Predefined in the Dataplex API schema | Google-managed templates in the global rule-library |
Organization-managed SQL templates in a custom rule library |
| Catalog attachment | Can be used only inside scan definitions | Can be referenced by scans and attached to catalog entries | Can be referenced by scans and attached to catalog entries |
| Glossary inheritance | Not supported | Supported through data-rules aspects |
Supported through data-rules aspects |
| SQL customization | Fixed logic | Fixed Google-managed logic | Full GoogleSQL with custom parameters |
| Execution identity | Default Dataplex Service Agent, customer-managed service account, or end-user credentials | Requires customer-managed service account | Requires customer-managed service account |
| When to use | Simple, single-table scans without catalog governance | Common validation checks shared across tables or glossaries | Domain-specific business logic or cross-table checks shared across teams |
To avoid unnecessary SQL maintenance, use system rule templates for standard checks, such as null, uniqueness, range, freshness, and schema checks. Reuse these templates whenever you share rules across scans or attach them to catalog entries. Create custom rule templates only when system templates don't cover your organization's SQL logic.
Metric differences from built-in rules
System rule templates evaluate SQL assertions and calculate certain metrics differently from equivalent built-in rules:
- Assertion row count metric: Knowledge Catalog
populates the
assertionRowCountmetric for all template reference rules, not only for custom SQL assertion rules. - Aggregate statistic range templates: templates such as Mean Range
Expectation, Min Range Expectation, and Max Range Expectation evaluate
aggregate statistics across the table. They don't support the
IGNORE_NULLcapability or report anullCountmetric. Each rule passes if the calculated aggregate statistic falls within the specified range. Uniqueness Expectation template: this template calculates
passedCountdifferently from the built-inUniquenessExpectationrule. The template returns every row that contains a duplicate value or null value as a failing row, which results in fewer passing rows when duplicates exist.For example, suppose a column contains the seven values
(a, a, b, b, c, d, e):- Built-in uniqueness rule: reports 5 passing rows:
(a, b, c, d, e). - Uniqueness rule template: returns 4 failing rows:
(a, a, b, b). The scan reports 3 passing rows, calculated as 7 total rows minus 4 failing rows:(c, d, e).
- Built-in uniqueness rule: reports 5 passing rows:
Rule binding models
After selecting your templates, choose how to bind rules to your BigQuery tables:
| Binding model | Where rules are stored | Updates propagate automatically | Best for |
|---|---|---|---|
| Direct template reference | Inside the DataScan specification |
Template SQL updates apply on next run; rule bindings are per-scan | Single-table scans, prototyping, or one-off checks |
| Table-attached catalog rules | data-rules aspect on the @bigquery table entry |
Yes, for catalog-based scans | Table-specific governance, rule discovery, and cloning rules across similar tables |
| Glossary-inherited catalog rules | data-rules aspect on a @dataplex glossary term entry |
Yes, to all linked tables and columns at scan runtime | Enterprise-wide semantic policies, such as PII, currency, or identifier standards |
Choose the binding model that matches your governance scope:
- Glossary-inherited catalog rules: enforce organization-wide semantic standards across linked columns.
- Table-attached catalog rules: support dataset-specific checks that teams discover and audit in the catalog.
- Direct template references: enable fast scan-scoped checks without attaching catalog metadata.
SQL query syntax for rule templates
When you author a custom rule template, you provide a GoogleSQL
statement that returns invalid rows. If the query returns one or more rows,
then the rule fails; if it returns zero rows, then the rule passes. For more
information about assertion semantics, see
SqlAssertion.
Follow these syntax rules when writing rule template SQL:
- Omit the trailing semicolon (
;) from the SQL statement. - Reference custom input parameters with
${param(PARAMETER_NAME)}(for example,${param(min_value)}). - Escape a literal
${...}string as$${...}so Knowledge Catalog doesn't evaluate it as a parameter. - Match exact casing because all parameter names are case-sensitive.
System-supported parameters
You can include the following system parameters in your rule template SQL:
| Parameter | Description |
|---|---|
${project()} |
The backtick-quoted Google Cloud project ID of the scanned resource, formatted as `PROJECT_ID`. Don't wrap it in additional backticks in SQL. |
${dataset()} |
The backtick-quoted BigQuery dataset of the scanned resource, formatted as `PROJECT_ID.DATASET_ID`. Don't wrap it in additional backticks in SQL. |
${table()} |
The backtick-quoted BigQuery table of the scanned resource, formatted as `PROJECT_ID.DATASET_ID.TABLE_ID`. Don't wrap it in additional backticks in SQL. |
${column()} |
The column on which the rule is evaluated. If a rule attached at the table level references ${column()}, then rule evaluation fails with an error. |
${data()} |
A reference to the scanned source table with all scan precondition filters applied, including row filters, sampling percentages, and incremental filters. For more information, see Data reference parameter. |
Template capabilities
When defining a custom template, you can declare optional capabilities in the
capabilities field to control which rule-level settings you can configure:
THRESHOLD: lets rules referencing the template specify a passing threshold ratio between0.0and1.0. DeclareTHRESHOLDonly when your SQL query evaluates one row at a time over${data()}.IGNORE_NULL: lets rules referencing the template ignoreNULLvalues in the evaluated column when computing pass ratios. You can declareIGNORE_NULLonly when the template also declaresTHRESHOLDand evaluates${column()}on a column-level attachment.
Range validation example
The following template SQL verifies that every value in a column falls within a configured minimum and maximum range:
SELECT *
FROM ${data()}
WHERE
NOT ((${column()} >= ${param(min_value)} AND ${column()} <= ${param(max_value)}) IS TRUE)
This query follows three key patterns:
NOT ((...) IS TRUE)returns rows withNULLvalues in the column as invalid rows unless the rule enablesignore_null.${data()}scopes evaluation to the table rows selected by the scan's row filter, sampling percentage, and incremental window.${column()}dynamically binds the query to whichever column the rule targets.
Foreign key validation example
The following template SQL verifies that every value in the target column exists in a primary key column of a reference table:
SELECT t.*
FROM ${data()} AS t
LEFT JOIN `${param(reference_table)}` AS s
ON t.${column()} = s.`${param(reference_column)}`
WHERE s.`${param(reference_column)}` IS NULL
This template defines two custom input parameters:
reference_table: the BigQuery reference table containing valid primary keys, formatted asPROJECT_ID.DATASET_ID.TABLE_ID.reference_column: the name of the primary key column in the reference table.
Because custom parameters perform raw text substitution without SQL escaping,
backticks around `${param(reference_table)}` and
`${param(reference_column)}` don't prevent SQL breakout if a caller passes
crafted values in templateReference.values.
Metadata aspects
When you define custom rule templates or attach rules to catalog entries using
the REST API or Terraform, you configure two built-in system aspect types in the
dataplex-types project. Use data-rules to attach rule instances to tables
and glossary terms, and use data-quality-rule-template to define custom rule
templates. For an overview of system aspect types, see
About aspects and aspect types.
Data rules aspect fields
To attach validation rules to a BigQuery table or business
glossary term, use the dataplex-types.global.data-rules aspect type. The
following table describes the fields for this aspect:
| Field | Type | Description |
|---|---|---|
rules |
Array | Required. List of data quality rule objects. |
rules[].name |
String | Required. Mutable name for the rule. Must be 1–63 characters, contain only letters, numbers, or hyphens, start with a letter, and end with a letter or number. |
rules[].dimension |
String | Optional. Data quality dimension (for example, VALIDITY or a custom uppercase name up to 30 characters). |
rules[].description |
String | Optional. Description of the rule (up to 1,024 characters). |
rules[].suspended |
Boolean | Optional. Whether the rule is paused. Default is false. |
rules[].threshold |
Double | Optional. Minimum passing row ratio from 0.0 to 1.0. Default is 1.0. Valid only for templates with the THRESHOLD capability. |
rules[].ignore_null |
Boolean | Optional. If true, then Knowledge Catalog ignores rows with NULL values in the target column when calculating the pass ratio. Default is false. Valid only for templates with the IGNORE_NULL capability. |
rules[].attributes |
Map | Optional. Custom string key-value pairs used for AIP-160 rule filtering. |
rules[].type |
Enum | Required. Rule type. The supported value is TEMPLATE_REFERENCE. |
rules[].templateReference |
Object | Required. Reference to a system or custom rule template. |
rules[].templateReference.name |
String | Required. Full resource name of the rule template entry. |
rules[].templateReference.values |
Map | Optional. Parameter names mapped to value objects. |
rules[].templateReference.values.PARAMETER_NAME.value |
String | Required. String value substituted for the parameter. |
The target column isn't stored as a field inside the data-rules aspect
payload. Instead, Knowledge Catalog determines the
target column from the attachment path. For BigQuery table
entries, the path is the schema column path (for example, @Schema.email); for
business glossary terms, the column is mapped through the term's
EntryLink.
The following example shows a data-rules aspect JSON payload:
{
"aspects": {
"dataplex-types.global.data-rules@Schema.email": {
"aspectType": "projects/dataplex-types/locations/global/aspectTypes/data-rules",
"data": {
"rules": [
{
"name": "valid-email",
"dimension": "VALIDITY",
"type": "TEMPLATE_REFERENCE",
"templateReference": {
"name": "projects/test-project/locations/us-central1/entryGroups/test-rules/entries/email-check",
"values": {
"pattern": {
"value": "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$"
}
}
},
"attributes": {
"environment": "prod"
}
}
]
}
}
}
}
Rule template aspect fields
To define a custom rule template entry, attach the
dataplex-types.global.data-quality-rule-template aspect. The following table
describes the fields for this aspect:
| Field | Type | Description |
|---|---|---|
dimension |
String | Required. Default dimension for rules referencing this template (uppercase, up to 30 characters). |
sqlCollection |
Array | Required. List of SQL query objects. Supports one SQL query. |
sqlCollection[].query |
String | Required. Parameterized GoogleSQL query that returns invalid rows. |
inputParameters |
Map | Optional. Map of parameter names to parameter description objects. |
inputParameters.PARAMETER_NAME.description |
String | Optional. Informational description of the parameter's expected type and usage. |
inputParameters.PARAMETER_NAME.defaultValue |
String | Optional. Default string value used if a rule omits the parameter. |
capabilities |
Array | Optional. List of supported capabilities (THRESHOLD or IGNORE_NULL). |
The following example shows a data-quality-rule-template entry JSON payload:
{
"entryType": "projects/dataplex-types/locations/global/entryTypes/data-quality-rule-template",
"aspects": {
"dataplex-types.global.data-quality-rule-template": {
"data": {
"dimension": "VALIDITY",
"sqlCollection": [
{
"query": "SELECT * FROM ${data()} WHERE NOT ((${column()} >= ${param(min_value)} AND ${column()} <= ${param(max_value)}) IS TRUE)"
}
],
"inputParameters": {
"min_value": {
"description": "Minimum inclusive numeric value.",
"defaultValue": "0"
},
"max_value": {
"description": "Maximum inclusive numeric value."
}
},
"capabilities": [
"THRESHOLD",
"IGNORE_NULL"
]
}
}
}
}
Enterprise security and governance
To keep central rule governance separate from pipeline operations under the principle of least privilege, Knowledge Catalog enforces explicit identity and authorization boundaries:
- Mandatory customer-managed execution identity: data quality scans that reference rule templates or catalog-based rules must attach a customer-managed service account. During scan execution, the Google-managed Dataplex Service Agent impersonates that service account using short-lived credentials to read target tables and run BigQuery jobs in your scan project.
- Separation of concerns: data stewards hold write access to rule libraries and glossary terms, while data engineers only need read access to referenced templates and scan permissions on target tables.
- Entry-group governance boundaries: rules attached as
data-rulesaspects inherit the Identity and Access Management (IAM) boundaries of the@bigqueryentry group for table entries and the@dataplexentry group for business glossary terms.
To configure granular IAM roles and service accounts, see Required roles in Create and manage rule templates and Required roles in Apply data quality rules and run scans.
Limitations
The following limitations apply when designing rule libraries, catalog rules, and data quality scans:
- Regional template scope: a scan or catalog entry can reference a custom
rule template only if the template is in the same region as the scan or
entry, or in the
globallocation. System rule templates reside inglobaland work in any region. - Execution identity: scans using template references or catalog-based rules require a customer-managed service account. Running these scans with the default Dataplex Service Agent or end-user credentials isn't supported.
- Single SQL query per template: the
sqlCollectionarray in a custom rule template supports one SQL query. - Column parameter scope: templates that reference
${column()}fail during scan evaluation if they're attached at the table level instead of to a specific column. - Capability dependencies: you can specify
IGNORE_NULLonly on templates that also specifyTHRESHOLDand evaluate rules on a column. - Metadata import jobs: bulk
metadata import jobs don't
support importing
data-rulesordata-quality-rule-templateaspects.
For API request quotas and resource limits that apply to entries, aspects, and data scans, see Quotas and limits.
Pricing
Reusing data quality rules involves the following pricing components:
- BigQuery query processing: BigQuery bills for the validation query job that runs in your scan project under the execution service account. For more information, see BigQuery pricing.
- Knowledge Catalog scan processing: there's no separate Knowledge Catalog processing charge for scans using a custom execution service account because BigQuery bills for the underlying job.
- Metadata storage: Knowledge Catalog bills for
storing
data-rulesanddata-quality-rule-templateaspects as metadata storage. For more information, see Knowledge Catalog pricing.
What's next
- Learn how to create and manage rule templates to browse system templates and author custom parameterized SQL rules.
- Learn how to apply data quality rules and run scans on BigQuery tables and business glossary terms.
- Browse all predefined checks in the system rule templates list.
- Follow a tutorial to build a policy-as-code data quality workflow.
- Follow a tutorial to manage data quality rules as code with Terraform, Cloud Build, and GitHub.
- Learn about scans, dimensions, rule filtering, and built-in rules in the auto data quality overview.