sparkdq 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. sparkdq-0.1.0/LICENSE +201 -0
  2. sparkdq-0.1.0/PKG-INFO +162 -0
  3. sparkdq-0.1.0/README.md +136 -0
  4. sparkdq-0.1.0/pyproject.toml +128 -0
  5. sparkdq-0.1.0/setup.cfg +4 -0
  6. sparkdq-0.1.0/sparkdq/__init__.py +1 -0
  7. sparkdq-0.1.0/sparkdq/checks/__init__.py +33 -0
  8. sparkdq-0.1.0/sparkdq/checks/aggregate/__init__.py +0 -0
  9. sparkdq-0.1.0/sparkdq/checks/aggregate/count_checks/__init__.py +0 -0
  10. sparkdq-0.1.0/sparkdq/checks/aggregate/count_checks/count_between_check.py +110 -0
  11. sparkdq-0.1.0/sparkdq/checks/aggregate/count_checks/count_exact_check.py +92 -0
  12. sparkdq-0.1.0/sparkdq/checks/aggregate/count_checks/count_max_check.py +90 -0
  13. sparkdq-0.1.0/sparkdq/checks/aggregate/count_checks/count_min_check.py +90 -0
  14. sparkdq-0.1.0/sparkdq/checks/base_classes/__init__.py +0 -0
  15. sparkdq-0.1.0/sparkdq/checks/base_classes/base_comparison_check.py +100 -0
  16. sparkdq-0.1.0/sparkdq/checks/row_level/__init__.py +0 -0
  17. sparkdq-0.1.0/sparkdq/checks/row_level/date_checks/__init__.py +0 -0
  18. sparkdq-0.1.0/sparkdq/checks/row_level/date_checks/date_between_check.py +105 -0
  19. sparkdq-0.1.0/sparkdq/checks/row_level/date_checks/date_max_check.py +76 -0
  20. sparkdq-0.1.0/sparkdq/checks/row_level/date_checks/date_min_check.py +76 -0
  21. sparkdq-0.1.0/sparkdq/checks/row_level/null_checks/__init__.py +0 -0
  22. sparkdq-0.1.0/sparkdq/checks/row_level/null_checks/not_null_check.py +87 -0
  23. sparkdq-0.1.0/sparkdq/checks/row_level/null_checks/null_check.py +81 -0
  24. sparkdq-0.1.0/sparkdq/checks/row_level/numeric_checks/__init__.py +0 -0
  25. sparkdq-0.1.0/sparkdq/checks/row_level/numeric_checks/numeric_between_check.py +107 -0
  26. sparkdq-0.1.0/sparkdq/checks/row_level/numeric_checks/numeric_max_check.py +79 -0
  27. sparkdq-0.1.0/sparkdq/checks/row_level/numeric_checks/numeric_min_check.py +79 -0
  28. sparkdq-0.1.0/sparkdq/checks/row_level/timestamp_checks/__init__.py +0 -0
  29. sparkdq-0.1.0/sparkdq/checks/row_level/timestamp_checks/timestamp_between_check.py +104 -0
  30. sparkdq-0.1.0/sparkdq/checks/row_level/timestamp_checks/timestamp_max_check.py +80 -0
  31. sparkdq-0.1.0/sparkdq/checks/row_level/timestamp_checks/timestamp_min_check.py +80 -0
  32. sparkdq-0.1.0/sparkdq/core/__init__.py +13 -0
  33. sparkdq-0.1.0/sparkdq/core/base_check.py +160 -0
  34. sparkdq-0.1.0/sparkdq/core/base_config.py +110 -0
  35. sparkdq-0.1.0/sparkdq/core/check_results.py +106 -0
  36. sparkdq-0.1.0/sparkdq/core/severity.py +60 -0
  37. sparkdq-0.1.0/sparkdq/engine/__init__.py +4 -0
  38. sparkdq-0.1.0/sparkdq/engine/base_engine.py +47 -0
  39. sparkdq-0.1.0/sparkdq/engine/batch/__init__.py +0 -0
  40. sparkdq-0.1.0/sparkdq/engine/batch/check_runner.py +177 -0
  41. sparkdq-0.1.0/sparkdq/engine/batch/dq_engine.py +39 -0
  42. sparkdq-0.1.0/sparkdq/engine/batch/validation_result.py +114 -0
  43. sparkdq-0.1.0/sparkdq/engine/validation_summary.py +28 -0
  44. sparkdq-0.1.0/sparkdq/exceptions.py +105 -0
  45. sparkdq-0.1.0/sparkdq/factory/__init__.py +3 -0
  46. sparkdq-0.1.0/sparkdq/factory/check_config_registry.py +79 -0
  47. sparkdq-0.1.0/sparkdq/factory/check_factory.py +67 -0
  48. sparkdq-0.1.0/sparkdq/management/__init__.py +3 -0
  49. sparkdq-0.1.0/sparkdq/management/check_set.py +108 -0
  50. sparkdq-0.1.0/sparkdq/py.typed +1 -0
  51. sparkdq-0.1.0/sparkdq.egg-info/PKG-INFO +162 -0
  52. sparkdq-0.1.0/sparkdq.egg-info/SOURCES.txt +53 -0
  53. sparkdq-0.1.0/sparkdq.egg-info/dependency_links.txt +1 -0
  54. sparkdq-0.1.0/sparkdq.egg-info/requires.txt +1 -0
  55. sparkdq-0.1.0/sparkdq.egg-info/top_level.txt +1 -0
sparkdq-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Marcel Kennert
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
sparkdq-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: sparkdq
3
+ Version: 0.1.0
4
+ Summary: A declarative PySpark framework for row- and aggregate-level data quality validation.
5
+ Author-email: Marcel Kennert <marcel.kennert@gmx.de>
6
+ Project-URL: homepage, https://github.com/sparkdq-community/sparkdq
7
+ Project-URL: documentation, https://sparkdq-community.github.io/sparkdq/
8
+ Keywords: data-quality,data-validation,pyspark,spark,etl,data-pipeline,apache-spark,lightweight
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Information Technology
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Topic :: Software Development :: Libraries
14
+ Classifier: Topic :: Software Development :: Quality Assurance
15
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Operating System :: OS Independent
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: pyspark<4.0.0,>=3.5.0
25
+ Dynamic: license-file
26
+
27
+ [![CI Pipeline](https://github.com/sparkdq-community/sparkdq/actions/workflows/ci.yaml/badge.svg)](https://github.com/sparkdq-community/sparkdq/actions/workflows/ci.yaml)
28
+ [![codecov](https://codecov.io/gh/sparkdq-community/sparkdq/branch/main/graph/badge.svg?token=3TVZE8J2DN)](https://codecov.io/gh/sparkdq-community/sparkdq)
29
+ [![Docs](https://img.shields.io/badge/docs-online-blue.svg)](https://sparkdq-community.github.io/sparkdq/)
30
+ [![Python Versions](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12-blue.svg)](https://github.com/sparkdq-community/sparkdq)
31
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
32
+
33
+ # SparkDQ — Data Quality Validation for Apache Spark
34
+
35
+ Most data quality frameworks weren’t designed with PySpark in mind. They aren’t Spark-native and often lack proper support for declarative pipelines. Instead of integrating seamlessly, they require you to build custom wrappers around them just to fit into production workflows. This adds complexity and makes your pipelines harder to maintain. On top of that, many frameworks only validate data after processing — so you can’t react dynamically or fail early when data issues occur.
36
+
37
+ **SparkDQ** takes a different approach. It’s built specifically for PySpark — so you can define and run data quality checks directly inside your Spark pipelines, using Python. Whether you're validating incoming data, verifying outputs before persistence, or enforcing assumptions in your dataflow: SparkDQ helps you catch issues early, without adding complexity.
38
+
39
+ 🚀 See the [official documentation](https://sparkdq-community.github.io/sparkdq/) to learn more.
40
+
41
+ ## Quickstart Examples
42
+
43
+ SparkDQ lets you define checks either using a **Python-native** interface or via **declarative configuration** (e.g. YAML, JSON, or database-driven). Regardless of how you define them, all checks are added to a `CheckSet` — which you pass to the validation engine. That’s it! Choose the style that fits your use case, and SparkDQ takes care of the rest.
44
+
45
+ ### Python-Native Approach
46
+
47
+ ```python
48
+ from pyspark.sql import SparkSession
49
+
50
+ from sparkdq.checks import NullCheckConfig
51
+ from sparkdq.engine import BatchDQEngine
52
+ from sparkdq.management import CheckSet
53
+
54
+ spark = SparkSession.builder.getOrCreate()
55
+
56
+ df = spark.createDataFrame([
57
+ {"id": 1, "name": "Alice"},
58
+ {"id": 2, "name": None},
59
+ {"id": 3, "name": "Bob"},
60
+ ])
61
+
62
+ # Define checks using the Python-native interface (no external config needed)
63
+ check_set = CheckSet()
64
+ check_set.add_check(NullCheckConfig(check_id="my-null-check", columns=["name"]))
65
+
66
+ result = BatchDQEngine(check_set).run_batch(df)
67
+ print(result.summary())
68
+ ```
69
+
70
+ ### Declarative Approach
71
+
72
+ ```python
73
+ from pyspark.sql import SparkSession
74
+
75
+ from sparkdq.engine import BatchDQEngine
76
+ from sparkdq.management import CheckSet
77
+
78
+ spark = SparkSession.builder.getOrCreate()
79
+
80
+ df = spark.createDataFrame(
81
+ [
82
+ {"id": 1, "name": "Alice"},
83
+ {"id": 2, "name": None},
84
+ {"id": 3, "name": "Bob"},
85
+ ]
86
+ )
87
+
88
+ # Declarative configuration via dictionary
89
+ # Could be loaded from YAML, JSON, or any external system
90
+ check_definitions = [
91
+ {"check-id": "my-null-check", "check": "null-check", "columns": ["name"]},
92
+ ]
93
+ check_set = CheckSet()
94
+ check_set.add_checks_from_dicts(check_definitions)
95
+
96
+ result = BatchDQEngine(check_set).run_batch(df)
97
+ print(result.summary())
98
+ ```
99
+
100
+ SparkDQ is designed to integrate seamlessly into real-world systems. Instead of relying on a custom DSL or
101
+ rigid schemas, it accepts plain Python dictionaries for check definitions. This makes it easy to load checks
102
+ from YAML or JSON files, configuration tables in databases, or even remote APIs — enabling smooth integration
103
+ into orchestration tools, CI pipelines, and data contract workflows.
104
+
105
+ ## Installation
106
+
107
+ Install the latest stable version using pip:
108
+
109
+ ```
110
+ pip install sparkdq
111
+ ```
112
+
113
+ Alternatively, if you're using uv, a fast and modern Python package manager:
114
+
115
+ ```
116
+ uv add sparkdq
117
+ ```
118
+
119
+ The framework supports Python 3.10+ and is fully tested with PySpark 3.5.x. No additional Spark installation
120
+ is required when running inside environments like Databricks, AWS Glue, or EMR.
121
+
122
+ ## Why SparkDQ?
123
+
124
+ * ✅ **Robust Validation Layer**: Clean separation of check definition, execution, and reporting
125
+
126
+ * ✅ **Declarative or Programmatic**: Define checks via config files or directly in Python
127
+
128
+ * ✅ **Severity-Aware**: Built-in distinction between warning and critical violations
129
+
130
+ * ✅ **Row & Aggregate Logic**: Supports both record-level and dataset-wide constraints
131
+
132
+ * ✅ **Typed & Tested**: Built with type safety, testability, and extensibility in mind
133
+
134
+ * ✅ **Zero Overhead**: Pure PySpark, no heavy dependencies
135
+
136
+ ## Typical Use Cases
137
+
138
+ SparkDQ is built for modern data platforms that demand trust, transparency, and resilience.
139
+ It helps teams enforce quality standards early and consistently — across ingestion, transformation, and delivery layers.
140
+
141
+ Whether you're building a real-time ingestion pipeline or curating a data product for thousands of downstream users,
142
+ SparkDQ lets you define and execute checks that are precise, scalable, and easy to maintain.
143
+
144
+ Common Scenarios:
145
+
146
+ * ✅ Validating raw ingestion data
147
+
148
+ * ✅ Enforcing schema and content rules before persisting to a lakehouse (Delta, Iceberg, Hudi)
149
+
150
+ * ✅ Asserting quality conditions before analytics or ML training jobs
151
+
152
+ * ✅ Flagging critical violations in batch pipelines via structured summaries and alerts
153
+
154
+ * ✅ Driving Data Contracts: Use declarative checks in CI pipelines to catch issues before deployment
155
+
156
+ ## Let’s Build Better Data Together
157
+
158
+ ⭐️ Found this useful? Give it a star and help spread the word!
159
+
160
+ 📣 Questions, feedback, or ideas? Open an issue or discussion — we’d love to hear from you.
161
+
162
+ 🤝 Want to contribute? Check out [CONTRIBUTING.md](https://github.com/sparkdq-community/sparkdq/blob/main/CONTRIBUTING.md) to get started.
@@ -0,0 +1,136 @@
1
+ [![CI Pipeline](https://github.com/sparkdq-community/sparkdq/actions/workflows/ci.yaml/badge.svg)](https://github.com/sparkdq-community/sparkdq/actions/workflows/ci.yaml)
2
+ [![codecov](https://codecov.io/gh/sparkdq-community/sparkdq/branch/main/graph/badge.svg?token=3TVZE8J2DN)](https://codecov.io/gh/sparkdq-community/sparkdq)
3
+ [![Docs](https://img.shields.io/badge/docs-online-blue.svg)](https://sparkdq-community.github.io/sparkdq/)
4
+ [![Python Versions](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12-blue.svg)](https://github.com/sparkdq-community/sparkdq)
5
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
6
+
7
+ # SparkDQ — Data Quality Validation for Apache Spark
8
+
9
+ Most data quality frameworks weren’t designed with PySpark in mind. They aren’t Spark-native and often lack proper support for declarative pipelines. Instead of integrating seamlessly, they require you to build custom wrappers around them just to fit into production workflows. This adds complexity and makes your pipelines harder to maintain. On top of that, many frameworks only validate data after processing — so you can’t react dynamically or fail early when data issues occur.
10
+
11
+ **SparkDQ** takes a different approach. It’s built specifically for PySpark — so you can define and run data quality checks directly inside your Spark pipelines, using Python. Whether you're validating incoming data, verifying outputs before persistence, or enforcing assumptions in your dataflow: SparkDQ helps you catch issues early, without adding complexity.
12
+
13
+ 🚀 See the [official documentation](https://sparkdq-community.github.io/sparkdq/) to learn more.
14
+
15
+ ## Quickstart Examples
16
+
17
+ SparkDQ lets you define checks either using a **Python-native** interface or via **declarative configuration** (e.g. YAML, JSON, or database-driven). Regardless of how you define them, all checks are added to a `CheckSet` — which you pass to the validation engine. That’s it! Choose the style that fits your use case, and SparkDQ takes care of the rest.
18
+
19
+ ### Python-Native Approach
20
+
21
+ ```python
22
+ from pyspark.sql import SparkSession
23
+
24
+ from sparkdq.checks import NullCheckConfig
25
+ from sparkdq.engine import BatchDQEngine
26
+ from sparkdq.management import CheckSet
27
+
28
+ spark = SparkSession.builder.getOrCreate()
29
+
30
+ df = spark.createDataFrame([
31
+ {"id": 1, "name": "Alice"},
32
+ {"id": 2, "name": None},
33
+ {"id": 3, "name": "Bob"},
34
+ ])
35
+
36
+ # Define checks using the Python-native interface (no external config needed)
37
+ check_set = CheckSet()
38
+ check_set.add_check(NullCheckConfig(check_id="my-null-check", columns=["name"]))
39
+
40
+ result = BatchDQEngine(check_set).run_batch(df)
41
+ print(result.summary())
42
+ ```
43
+
44
+ ### Declarative Approach
45
+
46
+ ```python
47
+ from pyspark.sql import SparkSession
48
+
49
+ from sparkdq.engine import BatchDQEngine
50
+ from sparkdq.management import CheckSet
51
+
52
+ spark = SparkSession.builder.getOrCreate()
53
+
54
+ df = spark.createDataFrame(
55
+ [
56
+ {"id": 1, "name": "Alice"},
57
+ {"id": 2, "name": None},
58
+ {"id": 3, "name": "Bob"},
59
+ ]
60
+ )
61
+
62
+ # Declarative configuration via dictionary
63
+ # Could be loaded from YAML, JSON, or any external system
64
+ check_definitions = [
65
+ {"check-id": "my-null-check", "check": "null-check", "columns": ["name"]},
66
+ ]
67
+ check_set = CheckSet()
68
+ check_set.add_checks_from_dicts(check_definitions)
69
+
70
+ result = BatchDQEngine(check_set).run_batch(df)
71
+ print(result.summary())
72
+ ```
73
+
74
+ SparkDQ is designed to integrate seamlessly into real-world systems. Instead of relying on a custom DSL or
75
+ rigid schemas, it accepts plain Python dictionaries for check definitions. This makes it easy to load checks
76
+ from YAML or JSON files, configuration tables in databases, or even remote APIs — enabling smooth integration
77
+ into orchestration tools, CI pipelines, and data contract workflows.
78
+
79
+ ## Installation
80
+
81
+ Install the latest stable version using pip:
82
+
83
+ ```
84
+ pip install sparkdq
85
+ ```
86
+
87
+ Alternatively, if you're using uv, a fast and modern Python package manager:
88
+
89
+ ```
90
+ uv add sparkdq
91
+ ```
92
+
93
+ The framework supports Python 3.10+ and is fully tested with PySpark 3.5.x. No additional Spark installation
94
+ is required when running inside environments like Databricks, AWS Glue, or EMR.
95
+
96
+ ## Why SparkDQ?
97
+
98
+ * ✅ **Robust Validation Layer**: Clean separation of check definition, execution, and reporting
99
+
100
+ * ✅ **Declarative or Programmatic**: Define checks via config files or directly in Python
101
+
102
+ * ✅ **Severity-Aware**: Built-in distinction between warning and critical violations
103
+
104
+ * ✅ **Row & Aggregate Logic**: Supports both record-level and dataset-wide constraints
105
+
106
+ * ✅ **Typed & Tested**: Built with type safety, testability, and extensibility in mind
107
+
108
+ * ✅ **Zero Overhead**: Pure PySpark, no heavy dependencies
109
+
110
+ ## Typical Use Cases
111
+
112
+ SparkDQ is built for modern data platforms that demand trust, transparency, and resilience.
113
+ It helps teams enforce quality standards early and consistently — across ingestion, transformation, and delivery layers.
114
+
115
+ Whether you're building a real-time ingestion pipeline or curating a data product for thousands of downstream users,
116
+ SparkDQ lets you define and execute checks that are precise, scalable, and easy to maintain.
117
+
118
+ Common Scenarios:
119
+
120
+ * ✅ Validating raw ingestion data
121
+
122
+ * ✅ Enforcing schema and content rules before persisting to a lakehouse (Delta, Iceberg, Hudi)
123
+
124
+ * ✅ Asserting quality conditions before analytics or ML training jobs
125
+
126
+ * ✅ Flagging critical violations in batch pipelines via structured summaries and alerts
127
+
128
+ * ✅ Driving Data Contracts: Use declarative checks in CI pipelines to catch issues before deployment
129
+
130
+ ## Let’s Build Better Data Together
131
+
132
+ ⭐️ Found this useful? Give it a star and help spread the word!
133
+
134
+ 📣 Questions, feedback, or ideas? Open an issue or discussion — we’d love to hear from you.
135
+
136
+ 🤝 Want to contribute? Check out [CONTRIBUTING.md](https://github.com/sparkdq-community/sparkdq/blob/main/CONTRIBUTING.md) to get started.
@@ -0,0 +1,128 @@
1
+ [project]
2
+ name = "sparkdq"
3
+ version = "0.1.0"
4
+ description = "A declarative PySpark framework for row- and aggregate-level data quality validation."
5
+ authors = [{ name = "Marcel Kennert", email = "marcel.kennert@gmx.de" }]
6
+ readme = "README.md"
7
+ keywords = [
8
+ "data-quality",
9
+ "data-validation",
10
+ "pyspark",
11
+ "spark",
12
+ "etl",
13
+ "data-pipeline",
14
+ "apache-spark",
15
+ "lightweight"
16
+ ]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Developers",
20
+ "Intended Audience :: Information Technology",
21
+ "Intended Audience :: Science/Research",
22
+ "Topic :: Software Development :: Libraries",
23
+ "Topic :: Software Development :: Quality Assurance",
24
+ "Topic :: Scientific/Engineering :: Information Analysis",
25
+ "License :: OSI Approved :: MIT License",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Operating System :: OS Independent"
30
+ ]
31
+ requires-python = ">=3.10"
32
+ dependencies = [
33
+ "pyspark>=3.5.0,<4.0.0",
34
+ ]
35
+
36
+ [project.urls]
37
+ homepage = "https://github.com/sparkdq-community/sparkdq"
38
+ documentation = "https://sparkdq-community.github.io/sparkdq/"
39
+
40
+ [tool.uv]
41
+ default-groups = "all"
42
+
43
+ [dependency-groups]
44
+ dev = [
45
+ "pre-commit>=4.2.0,<5.0.0"
46
+ ]
47
+ lint = [
48
+ "ruff>=0.11.0,<1.0.0",
49
+ "mypy>=1.15.0,<2.0.0"
50
+ ]
51
+ test = [
52
+ "pytest>=8.3.5,<9.0.0",
53
+ "pytest-cov>=6.1.0,<7.0.0",
54
+ "pyarrow>=19.0.0,<20.0.0",
55
+ "numpy<2.0.0",
56
+ "pandas>=2.0.0"
57
+ ]
58
+ docs = [
59
+ "sphinx>=7.2.0,<8.0.0",
60
+ "sphinx-copybutton>=0.5.2,<1.0.0",
61
+ "sphinx-book-theme>=1.1.0,<2.0.0",
62
+ "myst-parser>=2.0.0,<3.0.0"
63
+ ]
64
+ jupyter = [
65
+ "notebook>=7.3.3,<8.0.0",
66
+ "ipykernel>=6.20.0,<7.0.0"
67
+ ]
68
+
69
+ [tool.mypy]
70
+ python_version = "3.11"
71
+ exclude = ["docs", "tests", "examples"]
72
+ strict = true
73
+ show_error_codes = true
74
+
75
+ [tool.ruff]
76
+ exclude = [
77
+ ".mypy_cache",
78
+ ".pytest_cache",
79
+ ".ruff_cache",
80
+ ".venv",
81
+ "docs",
82
+ ]
83
+ line-length = 110
84
+ target-version = "py311"
85
+
86
+ [tool.ruff.lint]
87
+ select = ["E", "F", "I", "N", "W"]
88
+ extend-ignore = ["N812", "N803"]
89
+
90
+ [tool.pytest.ini_options]
91
+ testpaths = ["tests"]
92
+ filterwarnings = [
93
+ "ignore:.*distutils Version classes are deprecated.*:DeprecationWarning",
94
+ "ignore:.*PYARROW_IGNORE_TIMEZONE.*:UserWarning",
95
+ ]
96
+
97
+ [tool.coverage.run]
98
+ source = ["sparkdq"]
99
+
100
+ [tool.semantic_release]
101
+ commit_message = "chore(release): {version} [skip ci]\n\nAutomatically generated by python-semantic-release"
102
+ commit_parser = "conventional"
103
+ major_on_zero = false
104
+ allow_zero_version = true
105
+ version_toml = ["pyproject.toml:project.version"]
106
+ version_variable = ["sparkdq/__init__.py:__version__"]
107
+
108
+ [tool.semantic_release.changelog]
109
+ exclude_commit_patterns = ["Merge branch*", "chore(release)*"]
110
+
111
+ [tool.semantic_release.commit_parser_options]
112
+ allowed_tags = [
113
+ "build",
114
+ "chore",
115
+ "ci",
116
+ "docs",
117
+ "feat",
118
+ "fix",
119
+ "perf",
120
+ "style",
121
+ "refactor",
122
+ "test",
123
+ ]
124
+ minor_tags = ["feat"]
125
+ patch_tags = ["fix", "perf", "refactor"]
126
+
127
+ [tool.semantic_release.branches.main]
128
+ match = "main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,33 @@
1
+ from .aggregate.count_checks.count_between_check import RowCountBetweenCheckConfig
2
+ from .aggregate.count_checks.count_exact_check import RowCountExactCheckConfig
3
+ from .aggregate.count_checks.count_max_check import RowCountMaxCheckConfig
4
+ from .aggregate.count_checks.count_min_check import RowCountMinCheckConfig
5
+ from .row_level.date_checks.date_between_check import DateBetweenCheckConfig
6
+ from .row_level.date_checks.date_max_check import DateMaxCheckConfig
7
+ from .row_level.date_checks.date_min_check import DateMinCheckConfig
8
+ from .row_level.null_checks.not_null_check import NotNullCheckConfig
9
+ from .row_level.null_checks.null_check import NullCheckConfig
10
+ from .row_level.numeric_checks.numeric_between_check import NumericBetweenCheckConfig
11
+ from .row_level.numeric_checks.numeric_max_check import NumericMaxCheckConfig
12
+ from .row_level.numeric_checks.numeric_min_check import NumericMinCheckConfig
13
+ from .row_level.timestamp_checks.timestamp_between_check import TimestampBetweenCheck
14
+ from .row_level.timestamp_checks.timestamp_max_check import TimestampMaxCheckConfig
15
+ from .row_level.timestamp_checks.timestamp_min_check import TimestampMinCheckConfig
16
+
17
+ __all__ = [
18
+ "NullCheckConfig",
19
+ "NotNullCheckConfig",
20
+ "RowCountMinCheckConfig",
21
+ "RowCountMaxCheckConfig",
22
+ "RowCountExactCheckConfig",
23
+ "RowCountBetweenCheckConfig",
24
+ "NumericMinCheckConfig",
25
+ "NumericMaxCheckConfig",
26
+ "NumericBetweenCheckConfig",
27
+ "DateMinCheckConfig",
28
+ "DateMaxCheckConfig",
29
+ "DateBetweenCheckConfig",
30
+ "TimestampMinCheckConfig",
31
+ "TimestampMaxCheckConfig",
32
+ "TimestampBetweenCheck",
33
+ ]
File without changes