Skip to content

[FEATURE] ExpectColumnTypeToBe #11963

Description

@joshua-stauffer

Use case

ExpectColumnValuesToBeOfType behaves as a row-level check on Pandas object columns
but as a schema-level check everywhere else (see #11076). The row-level check generates one result type, the schema-level check another. We're splitting that overloaded behavior out into two separate Expectations; ExpectColumnValuesToBeOfType will continue checking each row, and will eventually be restricted to Pandas backends, while ExpectColumnTypeToBe will explicitly validate at the schema level for all backends.

Proposed capability

A new BatchExpectation (not ColumnMapExpectation) that asserts a column's declared
type:

  • Supports SQLAlchemy dialects, Spark, and Pandas dtypes via the existing
    table.column_types metric.
  • Result is {"observed_value": "<type name>"} — no row-level fields, no mostly.
  • Type-matching semantics can reuse the existing _validate_sqlalchemy /
    _validate_spark / _validate_pandas aggregate logic in
    expect_column_values_to_be_of_type.py.

Is this a net-new capability or an enhancement?

New Expectation

Alternatives considered

A number of users have proposed adding additional metrics to ExpectColumnValuesToBeOfType so that we can return the ColumnMapExpectation result format. Those queries are potentially expensive, and won't return any new information for the backends currently following the BatchExpectation path, since the column type is enforced at schema level.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestfeature requestready-for-workTriaged, accepted, and specified well enough to start today -- the claiming gate

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions