Skip to content

Expose and generalize cast_column to enable struct → struct casting in more contexts #16579

Open
@kosiew

Description

@kosiew

Title

Expose and generalize cast_column to enable struct → struct casting in more contexts


Is your feature request related to a problem or challenge?

Currently, struct-to-struct casting is supported only in a limited scope within a specific module (e.g., #16371 NestedSchemaAdapter). This means that even though the feature exists, most DataFusion users can’t leverage it directly. This restriction also causes issues in scenarios like planning queries involving mixed or nullable struct fields, as seen in issues like #14396.


Describe the solution you'd like

We should consider generalizing the #16371 introduced cast_column function and using it in place of the current arrow::compute::cast throughout DataFusion wherever applicable. This would make struct casting more widely available and resolve current limitations in query planning and type inference.


Describe alternatives you've considered

An alternative would be to manually implement struct casting logic in multiple places as needed. However, this would lead to code duplication and inconsistencies. By centralizing around a general-purpose cast_column function, we gain clarity, consistency, and maintainability.


Additional context

select {'a': 1};
-- works fine

select {'a': 1} = {'a': 2, 'b': NULL};
-- fails: Cannot infer common argument type for comparison operation

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions