kosiew opened a new pull request, #21563:
URL: https://github.com/apache/datafusion/pull/21563
## Which issue does this PR close?
* Closes #20164
---
## Rationale for this change
This PR completes the cast unification effort by removing the remaining
public and example surface of `CastColumnExpr`. Keeping both `CastExpr` and
`CastColumnExpr` created a dual-node model that complicated maintenance,
increased the risk of divergence, and made it easier for downstream code to
reintroduce duplicated casting logic.
With prior PRs having unified planner, adapter, and downstream behavior
around field-aware `CastExpr`, this change finalizes the transition by:
* Eliminating the legacy expression type
* Updating examples and documentation to reflect the unified model
* Ensuring test coverage continues to validate SQL-visible and struct-aware
casting behavior
---
## What changes are included in this PR?
### Removal of `CastColumnExpr`
* Deleted `datafusion/physical-expr/src/expressions/cast_column.rs`
* Removed module and public re-export from `expressions/mod.rs`
* Updated all references to use `CastExpr` instead
### Example cleanup
* Removed `custom_file_casts` example:
* Deleted example file
* Removed module, enum variant, and match arm from
`custom_data_source/main.rs`
* Updated usage string and example list
* Removed entry from `datafusion-examples/README.md`
### Test updates and coverage preservation
* Migrated relevant struct-cast scenarios into `CastExpr` tests
* Consolidated field-aware casting tests into `cast.rs`
* Added/updated tests covering:
* Target field metadata preservation
* Nullability semantics
* Struct, nested struct, and scalar struct casting
* Renamed helper (`assert_cast_column` → `assert_cast_input_column`) for
clarity
### Documentation updates
* Added upgrade note indicating removal of `CastColumnExpr`
* Documented migration path to `CastExpr::new_with_target_field`
### Internal refactoring
* Removed branching on `CastColumnExpr` in adapters and examples
* Ensured all casting paths rely on field-aware `CastExpr`
---
## Are these changes tested?
Yes.
* Existing tests were updated to reflect the unified cast model
* Coverage from deleted `cast_column.rs` tests was preserved and migrated
into `cast.rs`
* Added tests for:
* Struct casting (including missing fields)
* Nested struct casting
* Scalar struct casting
* Field metadata and nullability semantics
* Adapter and schema rewriting tests updated accordingly
All relevant crate tests pass, including casting, adapter, and regression
coverage.
---
## Are there any user-facing changes?
Yes.
### Breaking change
* `CastColumnExpr` has been removed from the public API
### Migration guidance
* Use `CastExpr` instead:
* Downcast to `CastExpr` instead of `CastColumnExpr`
* Use `target_field()` to access output field metadata
* Use `expr()` to access the input expression
* Use `CastExpr::new_with_target_field(...)` for field-aware casting
### Examples
* The `custom_file_casts` example has been removed as it demonstrated the
old dual-node model
Documentation has been updated accordingly.
---
## LLM-generated code disclosure
This PR includes LLM-generated code and comments. All LLM-generated content
has been manually reviewed and tested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]