Skip to content

[MAINTENANCE] Add SQL result_format regression coverage for expect_column_values_to_be_unique - #11964

Closed
joshua-stauffer wants to merge 9 commits into
developfrom
m/unique-result-format-regression-guards
Closed

[MAINTENANCE] Add SQL result_format regression coverage for expect_column_values_to_be_unique#11964
joshua-stauffer wants to merge 9 commits into
developfrom
m/unique-result-format-regression-guards

Conversation

@joshua-stauffer

Copy link
Copy Markdown
Collaborator

Summary

Adds regression coverage for ExpectColumnValuesToBeUnique result_format behaviors on SQL backends (PostgreSQL, SQLite). These behaviors depend on internals of the column_values.unique metric that are easy to break when its SQL implementation changes, and were previously untested:

  • COMPLETE + unexpected_index_column_names composed with a row_condition — the test data is constructed so a value is duplicated only when the filtered-out row is included, proving the condition is applied and the index list hydrates correctly.
  • include_unexpected_rows composed with a row_condition.
  • unexpected_index_query must be executable against the source database and return exactly the unexpected rows (the query string is surfaced to users in validation results and Data Docs).
  • exclude_unexpected_values=True must return the columnar {index_column: [values, ...]} index-list shape shared by all SQL map expectations.
  • Importing great_expectations must not emit metric re-registration warnings on stderr.

Changes

  • tests/integration/data_sources_and_expectations/expectations/test_expect_column_values_to_be_unique.py: five new tests plus a dedicated dataset and a small helper that fails loudly if any metric raised instead of producing a value.

Testing

  • SQLite parameterizations and the unit-marked import test run and pass locally against develop.
  • Ruff check and format (pinned pre-commit version) are clean.

…_be_unique

Pin down behaviors of the column_values.unique metric on SQL backends that
are easy to break when its implementation changes:

- COMPLETE + unexpected_index_column_names composed with a row_condition
- include_unexpected_rows composed with a row_condition
- unexpected_index_query must execute against the source database and
  return exactly the unexpected rows
- exclude_unexpected_values must return the columnar index-list shape
  shared by all SQL map expectations
- importing great_expectations must not emit metric re-registration
  warnings on stderr
@netlify

netlify Bot commented Jul 10, 2026

Copy link
Copy Markdown

Deploy Preview for niobium-lead-7998 ready!

Name Link
🔨 Latest commit cac2efb
🔍 Latest deploy log https://app.netlify.com/projects/niobium-lead-7998/deploys/6a5e1252bc6429000867ced1
😎 Deploy Preview https://deploy-preview-11964.docs.greatexpectations.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@joshua-stauffer
joshua-stauffer marked this pull request as ready for review July 10, 2026 09:23
- Narrow batch.datasource to SQLDatasource before calling get_engine()
  (mypy attr-defined)
- Allow 30s for the subprocess import test; the default unit timeout of
  2s is too tight for a full library import
The ignore on the NotImported fallback assignment is only needed when
pyarrow is installed (mypy then types the name as Module). In
environments without pyarrow the module resolves as Any, and
--warn-unused-ignores fails the build. Adding unused-ignore makes the
ignore valid in both environments.
@cla-bot cla-bot Bot added the cla-signed label Jul 20, 2026
@joshua-stauffer
joshua-stauffer marked this pull request as draft July 22, 2026 08:34
leodrivera added a commit to leodrivera/great_expectations that referenced this pull request Jul 22, 2026
…nique

- Fix KeyError when row_condition is present: _named_source_subquery now
  always wraps the domain selectable in an explicit named projection
- Register a dedicated unexpected_index_query provider using the same
  join-back pattern as the other row-retrieval paths, so the query string
  surfaced in validation results and Data Docs is executable against the
  source database
- Reuse _get_sqlalchemy_customized_unexpected_index_list so
  exclude_unexpected_values returns the canonical columnar index-list shape
- Pull result_format regression tests from fivetran#11964

The metric re-registration warnings on import remain; resolving them
depends on a MapMetricProvider rework to support custom auxiliary
providers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@joshua-stauffer

Copy link
Copy Markdown
Collaborator Author

these tests will merge via #11863

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant