Skip to content

PhysicalExprAdapter should use SchemaAdapter logic for casting structs #18957

@a10y

Description

@a10y

Describe the bug

If we try and rewrite an expression that operates over a struct column, currently the DefaultPhysicalExprRewriter will fail b/c the arrow cast kernel uses an overly strict check for Struct castability, namely that the two structs have identical types.

let is_compatible =
can_cast_types(physical_field.data_type(), logical_field.data_type());

However, the DefaultSchemaAdapter does the right thing here, checking for backward-compatible schema compatibility using the can_cast_field function

(DataType::Struct(source_fields), DataType::Struct(target_fields)) => {
// validate_struct_compatibility returns Result<()>; on success we can cast structs
validate_struct_compatibility(source_fields, target_fields)?;
Ok(true)
}

To Reproduce

No response

Expected behavior

No response

Additional context

It's possible this is addressed by #18627, haven't had a chance to look through it yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions