Skip to content

feat(physical-expr): port TryCastExpr to try_to_proto / try_from_proto hooks#22637

Closed
koopatroopa787 wants to merge 3 commits into
apache:mainfrom
koopatroopa787:fix/22429-trycast-proto-hooks
Closed

feat(physical-expr): port TryCastExpr to try_to_proto / try_from_proto hooks#22637
koopatroopa787 wants to merge 3 commits into
apache:mainfrom
koopatroopa787:fix/22429-trycast-proto-hooks

Conversation

@koopatroopa787
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #22429

Rationale for this change

TryCastExpr serialization/deserialization lived in the central downcast chains in to_proto.rs and from_proto.rs. This PR moves it into self-contained try_to_proto / try_from_proto hooks on TryCastExpr itself, following the pattern established for NotExpr, NegativeExpr, IsNullExpr, IsNotNullExpr, and Literal.

What changes are included in this PR?

  • datafusion/physical-expr/src/expressions/try_cast.rs
    • Added #[cfg(feature = "proto")] fn try_to_proto(...) inside impl PhysicalExpr for TryCastExpr
    • Added #[cfg(feature = "proto")] impl TryCastExpr { pub fn try_from_proto(...) }
    • Added proto_tests module covering: encode, encode-error propagation, decode, reject-wrong-variant, missing-expr, missing-arrow-type, and decode-error propagation
  • datafusion/proto/src/physical_plan/to_proto.rs
    • Removed the TryCastExpr downcast arm; removed TryCastExpr from import list
  • datafusion/proto/src/physical_plan/from_proto.rs
    • Replaced the inline ExprType::TryCast arm with TryCastExpr::try_from_proto(proto, &decode_ctx)?

Are there any user-facing changes?

No. Serialization behaviour is identical; only the code location changed.

🤖 Generated with Claude Code

…o hooks

Move protobuf serialization/deserialization for TryCastExpr out of the
central downcast chains in to_proto.rs and from_proto.rs into dedicated
try_to_proto / try_from_proto hooks on TryCastExpr itself, following
the pattern established for NotExpr, NegativeExpr, IsNullExpr,
IsNotNullExpr, and Literal.

Closes apache#22429
Copilot AI review requested due to automatic review settings May 30, 2026 01:41
@github-actions github-actions Bot added physical-expr Changes to the physical-expr crates proto Related to proto crate labels May 30, 2026
Kanishk Sachan and others added 2 commits June 1, 2026 23:52
…tNode

PhysicalTryCastNode.arrow_type expects datafusion_proto_models::datafusion_common::ArrowType,
not datafusion_proto_models::protobuf::ArrowType (which is a distinct type from a different
generated module). Import ArrowType, EmptyMessage, and ArrowTypeEnum from the correct path.
@koopatroopa787
Copy link
Copy Markdown
Contributor Author

Closing — #22550 was merged to main which already ports TryCastExpr to try_to_proto/try_from_proto hooks. This PR is now superseded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-expr Changes to the physical-expr crates proto Related to proto crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port TryCastExpr to use try_to_proto / try_from_proto

1 participant