kosiew opened a new pull request, #21545:
URL: https://github.com/apache/datafusion/pull/21545
## Which issue does this PR close?
* Part of #20164
---
## Rationale for this change
Downstream components in DataFusion currently branch on both `CastExpr` and
`CastColumnExpr`, even though they represent equivalent semantics after recent
cast unification work. This duplication increases maintenance burden,
introduces unnecessary complexity, and raises the risk of inconsistent behavior
when evolving cast-related logic.
This PR simplifies downstream logic by collapsing these dual branches into a
single `CastExpr`-based handling path, aligning with the broader cast
unification effort.
---
## What changes are included in this PR?
* **Removed `CastColumnExpr` handling in downstream logic**:
* Eliminated branching specific to `CastColumnExpr` in:
* `equivalence/properties/mod.rs`
* `pruning/pruning_predicate.rs`
* **Unified cast substitution logic in ordering equivalence**:
* Replaced `substitute_cast_like_ordering` with `substitute_cast_ordering`
* Simplified implementation to only consider `CastExpr`
* Preserved correctness by ensuring:
* Exact child expression match
* Order-preserving (widening) casts only
* **Refactored pruning rewrite logic**:
* Introduced helper: `rewrite_cast_child_to_prunable`
* Removed duplicated validation and recursion logic across cast types
* Updated both `CastExpr` and `TryCastExpr` handling to reuse the helper
* **Test updates and cleanup**:
* Updated tests to use `CastExpr::new_with_target_field`
* Simplified test cases by removing vector-based equality conditions
* Removed obsolete test covering `CastColumnExpr`
* Renamed pruning test to reflect unified cast handling
* **Minor code cleanups**:
* Removed unused imports
* Simplified iterator chains and substitution logic
---
## Are these changes tested?
Yes.
* Existing pruning and equivalence tests were updated to reflect the unified
cast handling.
* Obsolete tests relying on `CastColumnExpr` were removed.
* Test cases were adjusted to ensure behavior remains unchanged, including:
* Ordering equivalence with cast substitutions
* Predicate pruning with cast expressions
These updates ensure no regression in behavior while validating the
simplified implementation.
---
## Are there any user-facing changes?
No.
This change is an internal refactor and does not modify user-facing APIs or
query behavior. It preserves existing semantics while improving maintainability.
---
## 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]