

# Data quality system table

With system tables for AWS Glue Data Quality, the results of each data quality run are stored in tables that you can query to track which rules fail, on which tables, and how your data changes between runs. The tables hold rule outcomes, profiling statistics, and anomaly observations from Data Quality runs on tables in the AWS Glue Data Catalog or within ETL. They are stored as fully managed tables in Amazon S3 Tables, in Apache Iceberg format. You can query them with Amazon Athena, Amazon Redshift, or any other engine that is compatible with Apache Iceberg.

With these tables, you can do the following.
+ Find the rules that fail most often, and on which tables.
+ Review the anomalies that AWS Glue Data Quality detected.
+ Track a statistic, such as the row count of a table, across runs.

**Note**  
To include Data Quality results from an AWS Glue ETL job or from your Amazon EMR pipelines in system tables, use the Data Quality transform from the required import for your language on AWS Glue version 6.0 and above or Amazon EMR 8.1 and above:  
Python: import from `awsdataquality.transforms`.
Scala: import `software.amazon.dataquality.EvaluateDataQuality`.

## How AWS Glue Data Quality system tables work
<a name="catalog-data-quality-system-table-how-it-works"></a>

AWS Glue writes rows when a data quality run completes: one row for each rule evaluated, plus profiling statistics and anomaly observations for the run.

### Storage location
<a name="catalog-data-quality-system-table-storage-location"></a>

AWS Glue stores the data in the `aws-catalog` table bucket in your account and Region, in the `data_quality` namespace.

```
aws-catalog/                                          # S3 Tables bucket (one per account and Region)
  +-- data_quality/                                   # Namespace
      +-- aws_data_quality_rule_results/              # Table
      +-- aws_data_quality_profiles/                  # Table
      +-- aws_data_quality_profiles_distributions/    # Table
      +-- aws_data_quality_observations/              # Table
```

The following query returns 10 rows from the `aws_data_quality_rule_results` table.

```sql
SELECT * FROM "s3tablescatalog/aws-catalog"."data_quality"."aws_data_quality_rule_results" LIMIT 10;
```

## Supported system tables
<a name="catalog-data-quality-system-table-supported"></a>

AWS Glue Data Quality has the following system tables:
+ `aws_data_quality_rule_results`: one row for each rule evaluated in a data quality run.
+ `aws_data_quality_profiles` provides profiling statistics for each run, such as `RowCount` and `Completeness`.
+ `aws_data_quality_profiles_distributions` provides histogram bins for each profiled column.
+ `aws_data_quality_observations` provides anomaly detection results: predicted bounds, actual value, and outcome.

The four tables aren't created when you enable system tables for data quality. Each table appears the first time a data quality evaluation run produces a result that will be recorded in the respective tables. For example, the first time you execute a data quality evaluation with a distribution analyzers is when the distributions table will get created.

## Enabling system tables
<a name="catalog-data-quality-system-table-enabling"></a>

For the permissions, encryption, and status checks that all Data Catalog system tables share, see [Use AWS Glue Data Catalog system tables](catalog-system-tables.md). To turn on the data quality system table, see [Turning system tables on and off](catalog-system-tables.md#catalog-export-turning-on-off).

Data Quality exports need no additional key policy statements. If either service principal statement is missing from your KMS key policy, enabling export still succeeds and `DataQuality.S3TablesExportState.Status` stays `ENABLED`, but no results are written, and the Data Quality runs that produced them still succeed. Results produced while the key policy is missing are not exported automatically after you correct it; new results export normally from that point. Data Quality retains the unwritten results for 14 days, so if you need them exported, contact AWS Support within that period after correcting the key policy.

## Table schemas
<a name="catalog-data-quality-system-table-schemas"></a>

The following sections describe the columns of each Data Quality system table.

### aws\_data\_quality\_rule\_results
<a name="catalog-data-quality-system-table-rule-results"></a>

The full name of the table is `"s3tablescatalog/aws-catalog"."data_quality"."aws_data_quality_rule_results"`. It is partitioned by `identity(evaluation_context)`, `identity(platform)`, and `day(stored_time)`.

The `aws_data_quality_rule_results` system table contains one row for each rule evaluated in a data quality run. `rule_result` contains an outcome such as `PASS`, `FAIL`, or `ERROR`. `evaluated_metrics` records the metrics used for that evaluation.

The following table describes the columns of the `aws_data_quality_rule_results` table.


| Column | Type | Required | Description | 
| --- | --- | --- | --- | 
| schema\_version | string | No | Version identifier for this row's field set | 
| evaluation\_context | string | Yes | Logical identity of the data asset being evaluated. Primary source-level anchor for the DQ result. | 
| platform | string | Yes | Compute or execution platform that produced the DQ result. | 
| dimensions | map<string,string> | No | Platform-specific execution identifiers and context metadata. | 
| dq\_result\_id | string | Yes | Unique identifier for the DQ result event. | 
| run\_id | string | Yes | Platform run identifier. For ETL this is typically job run ID; for EMR, run ID; for catalog-managed runs, DQ run ID. | 
| cluster\_id | string | No | Cluster identifier for EMR-based executions; null for platforms that do not expose a cluster identity. | 
| job\_name | string | No | Job name for ETL-based executions; null for other platforms. | 
| rule\_name | string | No | Canonical rule type or rule label evaluated for this result row. | 
| rule\_description | string | No | Human-readable rule expression or rule definition evaluated. | 
| rule\_result | string | No | Rule evaluation outcome, for example PASS, FAIL, or ERROR. | 
| evaluation\_message | string | No | Evaluation message or failure reason returned for the rule. | 
| evaluated\_rule | string | No | Concrete evaluated rule expression after parameter resolution. | 
| evaluated\_metrics | map<string,double> | No | Metric name to metric value map used to evaluate the rule. | 
| labels | map<string,string> | No | Additional publisher-defined labels for filtering and grouping. | 
| evaluation\_level | string | No | Scope of the evaluated statistic or rule, for example dataset, column, or multi-column scope. | 
| columns\_referenced | list<string> | No | Ordered list of columns referenced by the rule or underlying evaluated statistic. | 
| column\_name | string | No | Populate only for single-column rules; leave null for dataset-level or multi-column rules. | 
| catalog\_id | string | No | Catalog identifier for the evaluated table when available. | 
| database\_name | string | No | Database name for the evaluated table when available. | 
| table\_name | string | No | Table name for the evaluated table when available. | 
| ruleset\_name | string | Yes | Name of the ruleset associated with the rule result. | 
| descriptors | map<string,string> | No | Additional execution or configuration metadata emitted by the publisher. | 
| execution\_role\_arn | string | No | IAM role used to execute the DQ | 
| evaluation\_run\_mode | string | No | Identifier for origin of DQ run, for example on-demand run or via an evaluation configuration | 
| data\_quality\_evaluation\_config | string | No | Name of the Data Quality evaluation configuration when the data quality run initiates due to an evaluation configuration | 
| account\_id | string | No | AWS account associated with the DQ run. | 
| region\_name | string | No | AWS region in which the DQ result was produced. | 
| started\_time | timestamptz | No | Execution start timestamp for the DQ run. | 
| completed\_time | timestamptz | No | Execution completion timestamp for the DQ run. | 
| stored\_time | timestamptz | Yes | Timestamp at which the record was written to the system table. | 

### aws\_data\_quality\_profiles
<a name="catalog-data-quality-system-table-profiles"></a>

The full name of the table is `"s3tablescatalog/aws-catalog"."data_quality"."aws_data_quality_profiles"`. It is partitioned by `identity(evaluation_context)`, `identity(platform)`, and `day(stored_time)`.

One row describes one profiling statistic per run, such as `RowCount` and `Completeness`. `statistic_name` identifies the statistic, `statistic_value` holds its numeric value, and `referenced_datasets` identifies additional dataset aliases when applicable.

The following table describes the columns of the `aws_data_quality_profiles` table.


| Column | Type | Required | Description | 
| --- | --- | --- | --- | 
| schema\_version | string | No | Version identifier for this row's field set | 
| evaluation\_context | string | Yes | Logical identity of the data asset being evaluated. Primary source-level anchor for the profiling result. | 
| platform | string | Yes | Compute or execution platform that produced the profiling result. | 
| profile\_id | string | Yes | Identifier for the generated data profile associated with this profiling run. | 
| dq\_result\_id | string | Yes | Unique identifier for the DQ result event associated with this profile row. | 
| dimensions | map<string,string> | No | Platform-specific execution identifiers and context metadata. | 
| run\_id | string | Yes | Platform run identifier associated with the profiling result. | 
| cluster\_id | string | No | Cluster identifier for EMR-based executions; null for platforms that do not expose a cluster identity. | 
| job\_name | string | No | Job name for ETL-based executions; null for other platforms. | 
| statistic\_id | string | No | Unique identifier of the published statistic. | 
| statistic\_name | string | No | Canonical name of the published statistic, for example RowCount or Completeness. | 
| statistic\_value | double | No | Numeric value of the published profiling statistic. | 
| evaluation\_level | string | No | Scope of the statistic, for example dataset, column, or multi-column scope. | 
| columns\_referenced | list<string> | No | Ordered list of columns referenced by the statistic. | 
| column\_name | string | No | Populate only for single-column statistics; leave null for dataset-level or multi-column statistics. | 
| referenced\_datasets | list<string> | No | Ordered list of referenced dataset aliases when the statistic depends on additional datasets. | 
| statistic\_properties | map<string,string> | No | Additional statistic attributes and publisher-defined metadata for the profiling row. | 
| catalog\_id | string | No | Catalog identifier for the evaluated table when available. | 
| database\_name | string | No | Database name for the evaluated table when available. | 
| table\_name | string | No | Table name for the evaluated table when available. | 
| ruleset\_name | string | Yes | Name of the ruleset associated with the profiling result when applicable. | 
| descriptors | map<string,string> | No | Additional execution or configuration metadata emitted by the publisher. | 
| execution\_role\_arn | string | No | IAM role used to execute the DQ | 
| evaluation\_run\_mode | string | No | Identifier for origin of DQ run, for example on-demand run or via an evaluation configuration | 
| data\_quality\_evaluation\_config | string | No | Name of the Data Quality evaluation configuration when the data quality run initiates due to an evaluation configuration | 
| account\_id | string | No | AWS account associated with the profiling run. | 
| region\_name | string | No | AWS region in which the profiling result was produced. | 
| started\_time | timestamptz | No | Execution start timestamp for the profiling run. | 
| completed\_time | timestamptz | No | Execution completion timestamp for the profiling run. | 
| stored\_time | timestamptz | Yes | Timestamp at which the record was written to the system table. | 

### aws\_data\_quality\_profiles\_distributions
<a name="catalog-data-quality-system-table-profiles-distributions"></a>

The full name of the table is `"s3tablescatalog/aws-catalog"."data_quality"."aws_data_quality_profiles_distributions"`. It is partitioned by `identity(evaluation_context)`, `identity(platform)`, and `day(stored_time)`.

One row describes one distribution bin for each profiled column. Numeric bins use `bin_lower_bound` and `bin_upper_bound`; categorical bins use `bin_label`.

The following table describes the columns of the `aws_data_quality_profiles_distributions` table.


| Column | Type | Required | Description | 
| --- | --- | --- | --- | 
| schema\_version | string | No | Version identifier for this row's field set | 
| evaluation\_context | string | Yes | Logical identity of the data asset being evaluated. Primary source-level anchor for the distribution result. | 
| platform | string | Yes | Compute or execution platform that produced the distribution result. | 
| run\_id | string | Yes | Platform run identifier associated with the profiling result. | 
| cluster\_id | string | No | Cluster identifier for EMR-based executions; null for platforms that do not expose a cluster identity. | 
| job\_name | string | No | Job name for ETL-based executions; null for other platforms. | 
| profile\_id | string | Yes | Identifier for the generated data profile associated with this distribution row. | 
| dq\_result\_id | string | Yes | Unique identifier for the DQ result event associated with this distribution row. | 
| dimensions | map<string,string> | No | Platform-specific execution identifiers and context metadata. | 
| statistic\_id | string | No | Unique identifier of the distribution statistic whose bin is represented by this row. | 
| column\_name | string | No | Populate only for single-column distribution statistics; leave null for dataset-level or multi-column statistics. | 
| data\_type | string | No | Data type of the profiled values represented by the distribution. | 
| num\_bins | int | No | Total number of bins emitted for the distribution statistic. | 
| bin\_index | int | No | Zero-based bin position within the distribution. | 
| bin\_label | string | No | Label for categorical bins; null for numeric distributions. | 
| bin\_lower\_bound | string | No | Lower boundary for numeric bins; null for categorical distributions. | 
| bin\_upper\_bound | string | No | Upper boundary for numeric bins; null for categorical distributions. | 
| bin\_count | long | No | Count of records that fall into the represented bin. | 
| evaluation\_level | string | No | Scope of the statistic, for example dataset, column, or multi-column scope. | 
| columns\_referenced | list<string> | No | Ordered list of columns referenced by the distribution statistic. | 
| catalog\_id | string | No | Catalog identifier for the evaluated table when available. | 
| database\_name | string | No | Database name for the evaluated table when available. | 
| table\_name | string | No | Table name for the evaluated table when available. | 
| ruleset\_name | string | Yes | Name of the ruleset associated with the distribution result when applicable. | 
| descriptors | map<string,string> | No | Additional execution or configuration metadata emitted by the publisher. | 
| execution\_role\_arn | string | No | IAM role used to execute the DQ | 
| evaluation\_run\_mode | string | No | Identifier for origin of DQ run, for example on-demand run or via an evaluation configuration | 
| data\_quality\_evaluation\_config | string | No | Name of the Data Quality evaluation configuration when the data quality run initiates due to an evaluation configuration | 
| account\_id | string | No | AWS account associated with the distribution run. | 
| region\_name | string | No | AWS region in which the distribution result was produced. | 
| started\_time | timestamptz | No | Execution start timestamp for the distribution run. | 
| completed\_time | timestamptz | No | Execution completion timestamp for the distribution run. | 
| stored\_time | timestamptz | Yes | Timestamp at which the record was written to the system table. | 

### aws\_data\_quality\_observations
<a name="catalog-data-quality-system-table-observations"></a>

The full name of the table is `"s3tablescatalog/aws-catalog"."data_quality"."aws_data_quality_observations"`. It is partitioned by `identity(evaluation_context)`, `identity(platform)`, and `day(stored_time)`.

One row describes one observed statistic generated by anomaly detection. The predicted range is in `lower_bound` and `upper_bound`. Compare `actual_value` with `expected_value` and use `prediction_outcome` and `observation_message` to interpret the result.

The following table describes the columns of the `aws_data_quality_observations` table.


| Column | Type | Required | Description | 
| --- | --- | --- | --- | 
| schema\_version | string | No | Version identifier for this row's field set | 
| evaluation\_context | string | Yes | Logical identity of the data asset being evaluated. Primary source-level anchor for the observation result. | 
| platform | string | Yes | Compute or execution platform that produced the observation result. | 
| run\_id | string | Yes | Platform run identifier associated with the profiling result. | 
| cluster\_id | string | No | Cluster identifier for EMR-based executions; null for platforms that do not expose a cluster identity. | 
| job\_name | string | No | Job name for ETL-based executions; null for other platforms. | 
| dq\_result\_id | string | Yes | Unique identifier for the DQ result event associated with this observation row. | 
| dimensions | map<string,string> | No | Platform-specific execution identifiers and context metadata. | 
| statistic\_id | string | No | Unique identifier of the statistic evaluated for anomaly detection. | 
| statistic\_name | string | No | Canonical name of the statistic evaluated for anomaly detection. | 
| lower\_bound | double | No | Lower predicted bound for the statistic. | 
| upper\_bound | double | No | Upper predicted bound for the statistic. | 
| expected\_value | double | No | Expected value predicted for the statistic. | 
| actual\_value | double | No | Actual observed value of the statistic. | 
| recommended\_rules | list<string> | No | Recommended DQ rules generated from the observation result. | 
| observation\_message | string | No | Human-readable anomaly or observation message for the statistic. | 
| training\_input | string | No | Indicates whether the statistic was included or excluded from model training. | 
| training\_status | string | No | Training status or eligibility state for anomaly detection on the statistic. | 
| prediction\_outcome | string | No | Prediction outcome for the statistic, for example ANOMALY, NOT\_ANOMALY, or SKIPPED. | 
| observation\_mode | string | No | Observation generation mode, for example FIXED or SCHEDULED. | 
| evaluation\_level | string | No | Scope of the statistic, for example dataset, column, or multi-column scope. | 
| columns\_referenced | list<string> | No | Ordered list of columns referenced by the observed statistic. | 
| column\_name | string | No | Populate only for single-column statistics; leave null for dataset-level or multi-column statistics. | 
| catalog\_id | string | No | Catalog identifier for the evaluated table when available. | 
| database\_name | string | No | Database name for the evaluated table when available. | 
| table\_name | string | No | Table name for the evaluated table when available. | 
| descriptors | map<string,string> | No | Additional execution or configuration metadata emitted by the publisher. | 
| execution\_role\_arn | string | No | IAM role used to execute the DQ | 
| evaluation\_run\_mode | string | No | Identifier for origin of DQ run, for example on-demand run or via an evaluation configuration | 
| data\_quality\_evaluation\_config | string | No | Name of the Data Quality evaluation configuration when the data quality run initiates due to an evaluation configuration | 
| account\_id | string | No | AWS account associated with the observation run. | 
| region\_name | string | No | AWS region in which the observation result was produced. | 
| started\_time | timestamptz | No | Execution start timestamp for the observation run. | 
| completed\_time | timestamptz | No | Execution completion timestamp for the observation run. | 
| stored\_time | timestamptz | Yes | Timestamp at which the record was written to the system table. | 

## Querying Data Quality system tables
<a name="catalog-data-quality-system-table-querying"></a>

To query Data Quality system tables, integrate the `aws-catalog` S3 Tables bucket with the AWS Glue Data Catalog before querying it. See [Integrating with Amazon S3 Tables](glue-federation-s3tables.md). Readers need access to the Glue Data Catalog and the required Data Quality tables through IAM or AWS Lake Formation. Data Quality results can contain rule expressions, evaluation messages, table identifiers, and other information that you should share only with intended readers.

## Example queries
<a name="catalog-data-quality-system-table-examples"></a>

The following example queries show common ways to use the Data Quality system tables.

Rules that failed most often in the last 7 days

```sql
SELECT database_name, table_name, rule_name, count(*) AS failures
FROM "s3tablescatalog/aws-catalog"."data_quality"."aws_data_quality_rule_results"
WHERE rule_result = 'FAIL'
  AND completed_time >= current_timestamp - interval '7' day
GROUP BY 1, 2, 3
ORDER BY failures DESC;
```

In this query, replace `my-database` and `my-table` with your own values.

Row count of a table across runs

```sql
SELECT completed_time, statistic_value AS row_count
FROM "s3tablescatalog/aws-catalog"."data_quality"."aws_data_quality_profiles"
WHERE statistic_name = 'RowCount'
  AND database_name = 'my-database' AND table_name = 'my-table'
ORDER BY completed_time;
```

Anomalies detected in the last 7 days

```sql
SELECT database_name, table_name, statistic_name, actual_value,
       lower_bound, upper_bound, observation_message, completed_time
FROM "s3tablescatalog/aws-catalog"."data_quality"."aws_data_quality_observations"
WHERE prediction_outcome = 'ANOMALY'
  AND completed_time >= current_timestamp - interval '7' day
ORDER BY completed_time DESC;
```