Skip to content

Add a dedicated physical expression for struct-aware casting that mirrors the existing cast_column helper semantics. #17760

@kosiew

Description

@kosiew

1. Introduce CastColumnExpr expression node

  • Goal: Add a dedicated physical expression for struct-aware casting that mirrors the existing cast_column helper semantics.

  • Scope & Location: Implement in datafusion/physical-expr (expression definition, evaluation logic, scalar/array handling) and expose via the crate’s public API.

  • Key Tasks:

    • Define the CastColumnExpr struct with schema metadata (input field, target field) and implement PhysicalExpr.
    • Use datafusion_common::nested_struct::cast_column in evaluate for array and scalar cases, preserving nullability and field ordering.
    • Ensure type coercion rules and data_type / nullable methods reflect the target field accurately.
    • Add unit tests covering basic casts, missing child fields, null-padding, and nested structs.
    • Update documentation or module comments describing when to use CastColumnExpr.
  • Out of Scope: Any planner/optimizer integration, protobuf wiring, or schema-rewriter changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions