adriangb opened a new pull request, #20065:
URL: https://github.com/apache/datafusion/pull/20065
## Summary
Extracts the `ExpressionPlacement` enum from apache/datafusion#20036 to
provide a mechanism for expressions to indicate where they should be placed in
the query plan for optimal execution.
## Changes
- Add `ExpressionPlacement` enum in `datafusion-expr-common` with four
variants:
- `Literal` - constant values
- `Column` - simple column references
- `PlaceAtLeaves` - cheap expressions (like `get_field`) that can be
pushed to leaf nodes
- `PlaceAtRoot` - expensive expressions that should stay at root
- Add `placement()` method to:
- `Expr` enum
- `ScalarUDF` / `ScalarUDFImpl` traits (with default returning
`PlaceAtRoot`)
- `PhysicalExpr` trait (with default returning `PlaceAtRoot`)
- Physical expression implementations for `Column`, `Literal`, and
`ScalarFunctionExpr`
- Implement `placement()` for `GetFieldFunc` that returns `PlaceAtLeaves`
when accessing struct fields with literal keys
- Replace `is_expr_trivial()` function checks with `placement()` checks in:
- `datafusion/optimizer/src/optimize_projections/mod.rs`
- `datafusion/physical-plan/src/projection.rs`
## Test Plan
- [x] `cargo check` passes on all affected packages
- [x] `cargo test -p datafusion-optimizer` passes
- [x] `cargo test -p datafusion-physical-plan` passes (except unrelated zstd
feature test)
- [x] `cargo test -p datafusion-functions --lib getfield` passes
🤖 Generated with [Claude Code](https://claude.ai/code)
--
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]