feat: add DQDL support via EvaluateDataQuality (#205) - #289
Conversation
Wrap com.amazon.deequ.dqdl.EvaluateDataQuality so Python users can evaluate DQDL rulesets, including DataFreshness for checking how recent data is. Adds pydeequ.dqdl.EvaluateDataQuality with process() and processRows(), supporting additionalDataSources and pandas output, plus tests and docs.
| sources = { | ||
| alias: ensure_pyspark_df(spark_session, df)._jdf | ||
| for alias, df in (additionalDataSources or {}).items() | ||
| } |
There was a problem hiding this comment.
NIT: Prefer the existing to_scala_map helper from scala_utils for consistency rather than inlining PythonUtils.toScalaMap.
dqdl.py:94
return data._jdf, rulesetDefinition, spark_session._jvm.PythonUtils.toScalaMap(sources)vs scala_utils.py:92 which definesto_scala_mapas exactlyspark_session._jvm.PythonUtils.toScalaMap(d).
Refutation trail (why this survived the Critic's disprove pass)
Hypothesis (Investigator): Calling spark_session._jvm.PythonUtils.toScalaMap(sources) directly instead of the existing to_scala_map helper is an inconsistency / possible bug for empty maps.
Disprove attempt (Critic): Read scala_utils.py:83-92; to_scala_map is literally spark_session._jvm.PythonUtils.toScalaMap(d). The diff inlines the same call. For the None case, additionalDataSources or {} yields {}, so toScalaMap({}) produces an empty Scala map — the same construct used for empty tags elsewhere. Behaviorally equivalent; only a style inconsistency (bypasses the helper).
The Critic's default verdict is OVERTURNED. UPHELD findings are those it tried — and failed — to refute.
|
@sudsali Can you please review it. Thanks |
Issue #, if available: Closes #205
Description of changes:
Deequ already supports data freshness as a DQDL rule (awslabs/deequ#661, in every release since 2.0.14, including the 2.0.21 jar PyDeequ pins). PyDeequ doesn't expose DQDL, so Python users can't use it. This PR adds a thin wrapper around
com.amazon.deequ.dqdl.EvaluateDataQuality.Changes
pydeequ/dqdl.py:EvaluateDataQuality.processandprocessRows, matching the Scala API. SupportsadditionalDataSources={"alias": df}for rules likeRowCountMatch,pandas=Trueoutput, and pandas input (same asVerificationSuite.onData).tests/test_dqdl.py: output schema, passing and failingDataFreshnessrules (including the compliance metric),days/minutesunits,additionalDataSources, pandas output, row-level outcomes, and input validation.README.mdanddocs/source/pydeequ.rst: usage section and API docs.No changes to existing APIs or the Deequ dependency.
Notes
DataFreshnessdoesn't have row-level support in Deequ, soprocessRowslists it underDataQualityRulesSkip. The README says this.dqdldependency.Testing
pytest tests/test_dqdl.py tests/test_verification.py: 15 passed locally (Spark 3.5.9, Python 3.11, Java 17, Deequ 2.0.21-spark-3.5). black and flake8 pass on the new files.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.