Skip to content

[BUGFIX] ExpectColumnValuesToBeOfType returns full map-format result for all backends#11868

Open
EshwarCVS wants to merge 7 commits into
great-expectations:developfrom
EshwarCVS:develop
Open

[BUGFIX] ExpectColumnValuesToBeOfType returns full map-format result for all backends#11868
EshwarCVS wants to merge 7 commits into
great-expectations:developfrom
EshwarCVS:develop

Conversation

@EshwarCVS
Copy link
Copy Markdown
Contributor

@EshwarCVS EshwarCVS commented May 6, 2026

Summary

Fixes #11076ExpectColumnValuesToBeOfType was returning only
{"observed_value": <type>} for non-object Pandas dtypes, SQLAlchemy,
and Spark backends instead of the standard ColumnMapExpectation result
structure documented in the expectation.

Also confirms #11026 (accented characters in row_condition strings) is
already resolved via alphas8bit in legacy_row_conditions.py.

Changes

  • expect_column_values_to_be_of_type.py

    • Added table.row_count and column_values.nonnull.unexpected_count
      to get_validation_dependencies for all backends so missing/null
      stats are always available.
    • Added _build_map_result() helper that wraps aggregate type-check
      results through _format_map_output, computing nonnull_count from
      the null metric and preserving observed_value.
    • Updated _validate() to route non-map paths through _build_map_result.
  • test_expect_column_values_to_be_of_type.py

    • Added tests verifying the full result schema on success, failure, and
      columns containing nulls.

Before / After

Before:

{ "success": false, "result": { "observed_value": "StringType" } }

After:

{
  "success": false,
  "result": {
    "element_count": 5,
    "unexpected_count": 4,
    "unexpected_percent": 100.0,
    "partial_unexpected_list": [],
    "missing_count": 1,
    "missing_percent": 20.0,
    "unexpected_percent_total": 80.0,
    "unexpected_percent_nonmissing": 100.0,
    "observed_value": "StringType"
  }
}

EshwarCVS and others added 7 commits May 5, 2026 13:14
…ations#11206)

Pydantic coerces False/True to "False"/"True" when str appears before
Literal[False]/Literal[True] in a Union. Fix _get_annotation_type to
sort bool-like types to the front of generated Union types, so
index_col=False (and similar bool flags) are preserved correctly.

https://claude.ai/code/session_01ETHG72BuUQaQWWdtWDcQJM
…s full map-format result

For non-map backends (Pandas non-object dtype, SQLAlchemy, Spark), the
expectation previously returned only {"observed_value": ...}. It now returns
the complete ColumnMapExpectation result structure (element_count,
unexpected_count, unexpected_percent, missing_count, etc.) alongside
observed_value, matching the documented output schema.

Also confirmed great-expectations#11026 (accented chars in row_conditions) is already resolved
via alphas8bit in legacy_row_conditions.py.

https://claude.ai/code/session_014PRzTm8HD61UpoyPvE3ciH
@netlify
Copy link
Copy Markdown

netlify Bot commented May 6, 2026

👷 Deploy request for niobium-lead-7998 pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 4c202a1

@EshwarCVS
Copy link
Copy Markdown
Contributor Author

EshwarCVS commented May 6, 2026

Didn't see #11855
Similar changes in this PR can be ignored

@joshua-stauffer
Copy link
Copy Markdown
Member

thanks for the PR @EshwarCVS . This expectation is unusual in that the Pandas implementation behaves as a row level check, while the Spark and SQL implementations behave as a schema level check. We'll address the gap, but haven't settled on a solution yet. I'll leave this open, but will hold off reviewing for the time being.

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.

ExpectColumnValuesToBeOfType dq rule is not returning expected result format

2 participants