Skip to content

feat/Add --checks option to filter great-expectations export by quality/properties - #1617

Open
julienguilhempartner-spec wants to merge 15 commits into
datacontract:mainfrom
julienguilhempartner-spec:main
Open

julienguilhempartner-spec wants to merge 15 commits into
datacontract:mainfrom
julienguilhempartner-spec:main

Conversation

@julienguilhempartner-spec

Copy link
Copy Markdown
Contributor

Summary:
Adds a --checks option to datacontract export great-expectations allowing users to filter exported expectations by category: quality (rules from contract quality: blocks) and/or properties (constraints inferred from logical types). Omit the option to export both (unchanged behavior).

Key Changes:

  • great_expectations_exporter.py — New GreatExpectationsCheckCategory enum, fail-fast validation of categories, and conditional generation logic that skips property constraint processing when properties is not selected.
  • command_export.py — New --checks CLI option with dedicated parsing and validation.
  • great-expectations.md — Documentation of the new option.
  • test_export_great_expectations.py — Tests covering filtering, validation, and regression fix for unsupported types.

julienguilhempartner-spec and others added 5 commits September 11, 2026 16:46
Co-authored-by: julienguilhempartner-spec <276929201+julienguilhempartner-spec@users.noreply.github.com>
…options-for-export-great-expectations

Add --checks option to filter great-expectations export by quality/properties

@jschoedl jschoedl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

Comment thread datacontract/command_export.py Outdated
Comment on lines +581 to +595
def _parse_great_expectations_checks(value: Optional[str]) -> Optional[set[str]]:
"""Parse `--checks` into a set of `GreatExpectationsCheckCategory` values, or None if omitted."""
if value is None:
return None
categories = {v.strip().lower() for v in value.split(",") if v.strip()}
if not categories:
console.print("[red]Empty --checks specified.[/red]")
console.print(f"Available categories: {', '.join(sorted(_GE_VALID_CHECKS))}")
raise typer.Exit(code=1)
invalid = categories - _GE_VALID_CHECKS
if invalid:
console.print(f"[red]Invalid --checks specified: {', '.join(sorted(invalid))}[/red]")
console.print(f"Available categories: {', '.join(sorted(_GE_VALID_CHECKS))}")
raise typer.Exit(code=1)
return categories

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functionality is already implemented in _parse_enum_csv(...) in command_test.py. Please move it to datacontract/cli.py and only import it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! ✅

Moved _parse_enum_csv() to cli.py as a reusable utility (commit dc41a0d). Removed duplicate _parse_great_expectations_checks() from command_export.py. Both command modules now import from cli.py.

Comment thread datacontract/command_export.py Outdated
Comment thread datacontract/command_export.py Outdated
Comment thread docs/docs/exports/great-expectations.md Outdated
Comment thread tests/test_export_great_expectations.py Outdated
Comment thread tests/test_export_great_expectations.py Outdated
jschoedl and others added 10 commits September 16, 2026 16:37
Co-authored-by: Jakob Schödl <jakob.schoedl@mailbox.org>
Co-authored-by: Jakob Schödl <jakob.schoedl@mailbox.org>
Co-authored-by: Jakob Schödl <jakob.schoedl@mailbox.org>
Co-authored-by: Jakob Schödl <jakob.schoedl@mailbox.org>
Co-authored-by: Jakob Schödl <jakob.schoedl@mailbox.org>
- Move generic _parse_enum_csv() from command_test.py to datacontract/cli.py
- Update command_export.py to use _parse_enum_csv instead of _parse_great_expectations_checks
- Remove duplicate function _parse_great_expectations_checks and _GE_VALID_CHECKS constant
- Update command_test.py to import _parse_enum_csv from cli
- All tests pass (44 tests for Great Expectations export verified)
Remove the deferred CLI registration code that was causing F401 errors
for unused imports in cli.py. This code was not needed for the refactoring
of _parse_enum_csv to cli.py.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants