feat(physical-expr): port Literal to try_to_proto / try_from_proto hooks#22636
Open
koopatroopa787 wants to merge 1 commit into
Open
feat(physical-expr): port Literal to try_to_proto / try_from_proto hooks#22636koopatroopa787 wants to merge 1 commit into
koopatroopa787 wants to merge 1 commit into
Conversation
Move protobuf serialization/deserialization for Literal out of the central downcast chains in to_proto.rs and from_proto.rs into dedicated try_to_proto / try_from_proto hooks on Literal itself, following the pattern established for NotExpr, NegativeExpr, IsNullExpr, and IsNotNullExpr. Closes apache#22427
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors the protobuf serialization/deserialization of Literal physical expressions to use the per-expression try_to_proto / try_from_proto hook pattern (instead of being centrally handled in to_proto.rs / from_proto.rs).
Changes:
- Removed the inline
Literalarm fromserialize_physical_expr_with_converterinto_proto.rsand dropped the unusedLiteralimport. - Routed
ExprType::Literaldecoding throughLiteral::try_from_protoinfrom_proto.rs. - Added
try_to_protoimpl andtry_from_protoconstructor onLiteral, plus unit tests under aproto_testsmodule.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| datafusion/proto/src/physical_plan/to_proto.rs | Removed the inline literal serialization branch and unused Literal import. |
| datafusion/proto/src/physical_plan/from_proto.rs | Delegates literal decoding to Literal::try_from_proto. |
| datafusion/physical-expr/src/expressions/literal.rs | Adds try_to_proto/try_from_proto methods and proto tests for Literal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #22427
Rationale for this change
Literalserialization/deserialization lived in the central downcast chains into_proto.rsandfrom_proto.rs. This PR moves it into self-containedtry_to_proto/try_from_protohooks onLiteralitself, following the pattern established forNotExpr,NegativeExpr,IsNullExpr, andIsNotNullExpr.What changes are included in this PR?
datafusion/physical-expr/src/expressions/literal.rs#[cfg(feature = "proto")] fn try_to_proto(...)insideimpl PhysicalExpr for Literal#[cfg(feature = "proto")] impl Literal { pub fn try_from_proto(...) }proto_testsmodule with encode, null-literal, roundtrip, and reject-wrong-variant testsdatafusion/proto/src/physical_plan/to_proto.rsLiteraldowncast arm; removedLiteralfrom import listdatafusion/proto/src/physical_plan/from_proto.rsExprType::Literalarm withLiteral::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