Repository navigation
Commit 92323f7
fix(proto): preserve physical cast expression state (apache#25056)
## Which issue does this PR close?
- Closes apache#24615.
## Rationale for this change
Physical cast protobuf hooks did not serialize `CastExpr` options or
explicit target-field metadata. A round trip could therefore change cast
behavior, nullability, or metadata. The hooks also accessed fields
individually, so future fields could be omitted silently.
## What changes are included in this PR?
- Exhaustively destructure `CastExpr`, `TryCastExpr`, and their protobuf
messages.
- Preserve explicit target fields for `CAST` and `TRY_CAST` while
keeping legacy type-only payload behavior.
- Preserve all serializable Arrow cast/format options; reject custom
formatter factories instead of silently dropping them.
- Store decoded format strings in owned cast options.
- Regenerate protobuf models and document the `CastExpr::cast_options`
API adjustment.
The protobuf changes are additive and backward compatible.
## What is the testing strategy for this PR?
Added unit coverage for:
- target-field and cast-option round trips
- legacy payloads without the new fields
- explicit default-shaped targets
- malformed target-field types
- unsupported formatter factories
Validated with:
- `cargo test -p datafusion-physical-expr --features proto
expressions::cast::`
- `cargo test -p datafusion-physical-expr --features proto
expressions::try_cast::`
- `cargo clippy -p datafusion-physical-expr -p
datafusion-physical-expr-adapter --all-features --tests -- -D warnings`
- `cargo check -p datafusion-proto --all-features`
- `./ci/scripts/doc_prettier_check.sh --write --allow-dirty`
## Are there any user-facing changes?
Cast expressions now retain their options and explicit output-field
semantics across protobuf round trips. `CastExpr::cast_options()`
returns a borrowing `CastOptions<'_>` value rather than
`&CastOptions<'static>`; the upgrade guide documents migration for code
rebuilding casts.
---------
Co-authored-by: kosiew <[email protected]>1 parent 7fe6d47 commit 92323f7
10 files changed
Lines changed: 1281 additions & 54 deletions
File tree
- datafusion
- common/src/scalar
- expr-common/src
- physical-expr-adapter/src
- physical-expr/src/expressions
- proto-models
- proto
- src/generated
- proto/tests/cases/plans
- docs/source/library-user-guide/upgrading
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4377 | 4377 | | |
4378 | 4378 | | |
4379 | 4379 | | |
4380 | | - | |
| 4380 | + | |
4381 | 4381 | | |
4382 | 4382 | | |
4383 | 4383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
| 297 | + | |
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
| 315 | + | |
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
578 | 576 | | |
579 | 577 | | |
580 | 578 | | |
| |||
598 | 596 | | |
599 | 597 | | |
600 | 598 | | |
601 | | - | |
| 599 | + | |
602 | 600 | | |
603 | 601 | | |
604 | | - | |
605 | 602 | | |
606 | 603 | | |
607 | 604 | | |
| |||
0 commit comments