Skip to content

Why don't my Amazon EMR Data Quality results appear? Set up IAM and publishing correctly

7 minute read
Content level: Advanced
0

On October 12, 2026, Amazon EMR added native data quality checks for Apache Spark jobs. Amazon EMR Data Quality, powered by AWS Glue Data Quality, lets you validate data inside your Spark application, before bad data reaches downstream systems, at no additional cost. This article covers how evaluation works, where to validate in a pipeline, and the security, publishing, monitoring, and limitation details that keep your checks reliable and your results visible.

Introduction

Amazon EMR Data Quality is a Spark transform. You pass the EvaluateDataQuality transform a DataFrame and a ruleset written in Data Quality Definition Language (DQDL). It evaluates each rule with the same open-source Deequ engine that AWS Glue Data Quality uses, and returns a DataFrame with one outcome per rule: Passed, Failed, or Error. Your application can branch on that result, for example to stop a write.

Because EMR Data Quality uses the same DQDL rules language and APIs as AWS Glue, you can apply one approach across both engines. It works with Apache Iceberg, Apache Hudi, and Delta Lake, and supports more than 30 rule types, including dynamic rules that compare against previous runs and machine learning-based anomaly detection that tracks drift without fixed thresholds.

A minimal ruleset looks like this:

Rules = [
    RowCount > 100,
    IsComplete "customer_id",
    IsUnique "customer_id",
    ColumnValues "country" in ["US", "CA", "MX"]
]

Prerequisites

  • Use the AWS runtime for Apache Spark, release emr-spark-8.1.0 or later.

  • EMR Data Quality runs on Amazon EMR on EC2, Amazon EMR on EKS, and Amazon EMR Serverless.

  • EMR Data Quality supports Apache Spark applications only. It does not run on Hive, Trino, Flink, or other non-Spark engines on Amazon EMR.

  • The IAM role that your Amazon EMR Spark workload assumes, such as the EC2 instance profile attached to the cluster or a per-step runtime role, must have the permissions described in Security Best Practices.

How Evaluation Works

When your script calls EvaluateDataQuality.apply, the transform reads the DataFrame, evaluates every rule, and returns a results DataFrame with these columns:

  • Rule — the DQDL rule that was evaluated

  • Outcome — Passed, Failed, or Error

  • FailureReason — for failed rules, includes the observed value so you can triage without rerunning the job

  • EvaluatedMetrics

from awsdataquality.transforms import EvaluateDataQuality

results = EvaluateDataQuality.apply(
    frame=orders,
    ruleset=ruleset,
    publishing_options={
        "dataQualityEvaluationContext": "orders_daily",
        "enableDataQualityResultsPublishing": True,
    },
)
results.show(truncate=False)

By default, each evaluation is also published to AWS Glue Data Quality. Published results let you review run history, compare runs, and feed anomaly detection.

The data quality score is the percentage of rules that passed: rules passed / (rules passed + rules failed). Rules that error, and anomaly detection observations, do not affect the score.

Where to Validate in Your Pipeline

You can call EvaluateDataQuality anywhere in a Spark script. Three patterns are common:

  • Pre-validation — Evaluate raw input right after you read it, so the job stops early on upstream problems such as missing files, schema drift, or empty tables.

  • Inline validation — Evaluate an intermediate DataFrame between transformations, for example after a join or aggregation.

  • Post-validation — Evaluate the final DataFrame before you write it, and skip the write if a rule fails.

Gate a write on post-validation results by checking for both Failed and Error outcomes:

bad_rules = results.filter("Outcome in ('Failed', 'Error')").count()
if bad_rules > 0:
    raise RuntimeError(f"{bad_rules} data quality rule(s) failed or errored. Write skipped.")

curated.write.mode("overwrite").parquet("s3://amzn-s3-demo-bucket/orders_curated/")

Based on evaluation results, you can also filter invalid records or route them to a quarantine location instead of failing the job.

Security Best Practices

Required permissions for the Spark workload role:

  • Publish results — glue:PublishDataQuality. Publishing is on by default (enableDataQualityResultsPublishing is True), so grant this unless you explicitly set the option to False.

  • Load publishing configuration — glue:AccessDataQualityRuntimeConfiguration. Required whenever publishing is on.

  • CloudWatch metrics — cloudwatch:PutMetricData. Required only when you set enableDataQualityCloudWatchMetrics to True.

  • Data Catalog tables — glue:GetTable and glue:GetDatabase. Required when the DataFrame is read from an AWS Glue Data Catalog table, or when the application sets publishToDataCatalogTarget.

  • Saved rulesets — glue:GetDataQualityRuleset. Required only when your script loads a ruleset from the Data Catalog.

Important: If the role is missing glue:AccessDataQualityRuntimeConfiguration, the library silently disables publishing for that run. The job does not fail, and it still returns rule outcomes, but the run is not published. Grant this permission whenever publishing is on.

The following inline policy grants the minimum permissions to publish results:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "GlueDataQuality",
            "Effect": "Allow",
            "Action": [
                "glue:PublishDataQuality",
                "glue:AccessDataQualityRuntimeConfiguration"
            ],
            "Resource": "*"
        }
    ]
}

Add the other actions from the list above only for the features you use.

Ruleset Management Best Practices

  • Store shared rulesets in the AWS Glue Data Catalog. Author a ruleset once in the AWS Glue console or with the CreateDataQualityRuleset API, then load it at runtime. This lets you version a ruleset in one place and share it across EMR Spark workloads and AWS Glue ETL jobs.
import boto3
from awsdataquality.transforms import EvaluateDataQuality

glue = boto3.client("glue")
ruleset = glue.get_data_quality_ruleset(Name="orders_quality")["Ruleset"]

results = EvaluateDataQuality.apply(
    frame=orders,
    ruleset=ruleset,
    publishing_options={
        "dataQualityEvaluationContext": "orders_daily",
        "enableDataQualityResultsPublishing": True,
    },
)
  • Use a consistent evaluation context. Runs that share a dataQualityEvaluationContext value appear as one logical dataset in the AWS Glue console and in anomaly detection training, whether they came from an EMR Spark application or an AWS Glue ETL job. Use the same value every time you validate the same dataset.

Monitoring Best Practices

  • List and retrieve published runs with the AWS Glue Data Quality APIs (ListDataQualityResultsV2, GetDataQualityResultV2, BatchGetDataQualityResultV2) or the AWS CLI:
aws glue list-data-quality-results-v2 --max-results 5
aws glue get-data-quality-result-v2 --result-id <result-id>
  • To see a run on the Data quality tab of a Data Catalog table in the AWS Glue console, set publishToDataCatalogTarget with a DatabaseName and TableName. Without it, the run is published but is retrievable only through the API or AWS CLI.

  • To narrow results to one dataset, pass its evaluation context to ListDataQualityStatistics. When your application reads from a Data Catalog table, you can also filter list-data-quality-results-v2 by DataSource.GlueTable.

  • Set enableDataQualityCloudWatchMetrics to True to emit per-run pass and fail metrics to Amazon CloudWatch for dashboards and alarms.

  • Enable anomaly detection over the statistics that each run produces. Anomalies are reported as observations and do not reduce the data quality score.

Limitations to Plan For

  • A single ruleset can contain up to 2,000 rules.

  • The serialized DQDL source of a ruleset must be no larger than 65 KB.

  • Statistics are limited to 100,000 per account and are retained for up to two years. There is no cost to store them.

  • Only Apache Spark applications are supported. Hive, Trino, Flink, and other non-Spark engines on Amazon EMR are not.

  • Release emr-spark-8.1.0 or later is required.

Conclusion

Amazon EMR Data Quality lets you validate data inside your Spark applications with the same DQDL rules and APIs as AWS Glue. Grant glue:AccessDataQualityRuntimeConfiguration along with glue:PublishDataQuality so that runs are actually published, set publishToDataCatalogTarget when you want results in the AWS Glue console, and use a consistent evaluation context for each dataset. Gate writes on both Failed and Error outcomes, and check the limits before you design large rulesets.

References

AWS
EXPERT

published 5 days ago80 views