FAQ and Troubleshooting¶
Common Questions¶
My job fails with SparkExpectOrFailException¶
This means a rule with action_if_failed = "fail" has failed. Check the stats table for details on which rule triggered the failure:
SELECT source_agg_dq_results, final_agg_dq_results,
source_query_dq_results, final_query_dq_results,
row_dq_res_summary
FROM your_stats_table
WHERE meta_dq_run_id = 'your_run_id'
To make the job continue instead of failing, change the rule's action_if_failed to "ignore" or "drop".
How do I debug which rules failed?¶
- Stats table: Check
row_dq_res_summary,source_agg_dq_results, andfinal_agg_dq_resultscolumns. - Detailed stats table: Enable
se_enable_agg_dq_detailed_result: Trueand/orse_enable_query_dq_detailed_result: Truein your user_conf to get per-rule results in the<stats_table>_detailedtable. - Error table: Query
<target_table>_errorand inspect themeta_row_dq_resultscolumn to see which rules each row failed. - Debugger mode: Pass
debugger=Trueto theSparkExpectationsconstructor to print intermediate DataFrames to the driver logs.
Notifications are not being sent¶
- Check the enable flags: Ensure
se_notifications_enable_email,se_notifications_enable_slack, etc. are set toTrue. - Check the trigger flags: By default,
on_startisFalse. Setse_notifications_on_start: True,se_notifications_on_completion: True, orse_notifications_on_fail: Trueas needed. - Check connectivity: For email, verify SMTP host/port. For Slack/Teams/Zoom, verify the webhook URL is reachable.
- Serverless: Email notifications may not work in Databricks Serverless due to network restrictions. Use webhook-based notifications (Slack, Teams) instead.
SparkExpectationsDataframeNotReturnedException¶
The decorated function must return a DataFrame. Make sure your function has a return statement that returns a Spark DataFrame.
Rules from my YAML/JSON file are not loading¶
- Check
dq_env: If your file usesdq_env, you must passoptions={"dq_env": "DEV"}(or your environment name). - Check required fields: Each rule must have at least
rule,expectation, andrule_type. - Check
rule_type: Must be one ofrow_dq,agg_dq, orquery_dq. - Check file format: Use
load_rules_from_yaml()for.yaml/.ymlfiles andload_rules_from_json()for.jsonfiles, orload_rules()for auto-detection.
Kafka streaming fails with connection timeout¶
- Verify the Kafka broker URL and port are correct and reachable.
- If using Cerberus or Databricks secrets, verify the secret keys resolve to valid values.
- To disable Kafka streaming entirely, set
user_config.se_enable_streaming: Falsein yourstats_streaming_options.
How do I disable the error table?¶
Set se_enable_error_table: False in your user_conf. Note that this means failed rows will be silently dropped with no record.
How do I use dynamic parameters in rules?¶
Use se_dq_rules_params to pass a dictionary of parameters that get substituted into rule expressions:
In your rules, reference them with curly braces: (select count(*) from dq_spark_{env}.{table}) > 0.
What tables does Spark Expectations create?¶
| Table | Auto-created | Description |
|---|---|---|
| Target table | Written if write_to_table=True |
Clean data after DQ |
<target>_error |
Yes (unless disabled) | Rows that failed DQ rules |
| Stats table | Yes | Run-level metrics and results |
<stats>_detailed |
Only if se_enable_agg_dq_detailed_result=True or se_enable_query_dq_detailed_result=True |
Per-rule execution results for agg_dq and/or query_dq |
<stats>_querydq_output |
Only if se_enable_query_dq_detailed_result=True |
Query DQ sub-query results |
Getting Help¶
- GitHub Issues: Nike-Inc/spark-expectations/issues
- Releases: GitHub Releases