You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "chakkk309 (via GitHub)" <gi...@apache.org> on 2026/05/27 00:29:27 UTC

[PR] refactor: Port TryCastExpr proto serialization hooks [datafusion]

chakkk309 opened a new pull request, #22550:
URL: https://github.com/apache/datafusion/pull/22550

   ## Which issue does this PR close?
   
   - Closes #22429.
   
   ## Rationale for this change
   
   This is part of #22418, which migrates built-in `PhysicalExpr` implementations away from the central protobuf serialization / deserialization chains.
   
   `TryCastExpr` can now own its protobuf serialization through `PhysicalExpr::try_to_proto` and its deserialization through `TryCastExpr::try_from_proto`, matching the pattern used by previously migrated physical expressions.
   
   ## What changes are included in this PR?
   
   - Adds `PhysicalExpr::try_to_proto` support for `TryCastExpr`.
   - Adds `TryCastExpr::try_from_proto`.
   - Wires `TryCastExpr` deserialization in `from_proto.rs` through the new hook.
   - Removes the old `TryCastExpr` serialization branch from the central `to_proto.rs` downcast chain.
   - Adds direct proto hook tests for successful encoding / decoding and invalid protobuf inputs.
   
   ## Are these changes tested?
   
   Yes.
   
   I ran:
   
   ```bash
   cargo fmt --all --check
   git diff --check
   cargo test -p datafusion-physical-expr --features proto try_cast
   cargo test -p datafusion-proto --test proto_integration
   cargo clippy -p datafusion-physical-expr --features proto --tests -- -D warnings
   cargo clippy -p datafusion-proto --tests -- -D warnings
   ```
   
   ## Are there any user-facing changes?
   
   No. This is an internal protobuf serialization refactor for `TryCastExpr`; the wire format remains unchanged.
   


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] refactor: Port TryCastExpr proto serialization hooks [datafusion]

Posted by "adriangb (via GitHub)" <gi...@apache.org>.
adriangb merged PR #22550:
URL: https://github.com/apache/datafusion/pull/22550


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] refactor: Port TryCastExpr proto serialization hooks [datafusion]

Posted by "adriangb (via GitHub)" <gi...@apache.org>.
adriangb commented on PR #22550:
URL: https://github.com/apache/datafusion/pull/22550#issuecomment-4576157183

   @chakkk309 can you please resolve conflicts?


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] refactor: Port TryCastExpr proto serialization hooks [datafusion]

Posted by "adriangb (via GitHub)" <gi...@apache.org>.
adriangb commented on code in PR #22550:
URL: https://github.com/apache/datafusion/pull/22550#discussion_r3318792739


##########
datafusion/physical-expr/src/expressions/try_cast.rs:
##########
@@ -154,7 +217,20 @@ mod tests {
         },
         datatypes::*,
     };
+    #[cfg(feature = "proto")]
+    use datafusion_common::DataFusionError;
     use datafusion_physical_expr_common::physical_expr::fmt_sql;
+    #[cfg(feature = "proto")]
+    use datafusion_physical_expr_common::physical_expr::proto_decode::PhysicalExprDecodeCtx;
+    #[cfg(feature = "proto")]
+    use datafusion_physical_expr_common::physical_expr::proto_encode::PhysicalExprEncodeCtx;
+    #[cfg(feature = "proto")]
+    use datafusion_proto_models::protobuf::{self, physical_expr_node};
+
+    #[cfg(feature = "proto")]
+    use crate::proto_test_util::{
+        StubDecoder, StubEncoder, UnreachableDecoder, column_node,
+    };

Review Comment:
   It'd be easier to just make a new test module:
   
   https://github.com/apache/datafusion/blob/cab69a1d4aa8dab980e468e2ec8089ec66988fce/datafusion/physical-expr/src/expressions/like.rs#L348-L349



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] refactor: Port TryCastExpr proto serialization hooks [datafusion]

Posted by "adriangb (via GitHub)" <gi...@apache.org>.
adriangb commented on PR #22550:
URL: https://github.com/apache/datafusion/pull/22550#issuecomment-4567247511

   #22596 adds an `expect_expr_variant!` macro and a `require_proto_field` helper that together collapse the outer `match` and any non-expression "missing required field" `ok_or_else` to one line each. Could you rebase onto it and adopt them before final review?
   


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] refactor: Port TryCastExpr proto serialization hooks [datafusion]

Posted by "adriangb (via GitHub)" <gi...@apache.org>.
adriangb commented on PR #22550:
URL: https://github.com/apache/datafusion/pull/22550#issuecomment-4575437872

   thanks!


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] refactor: Port TryCastExpr proto serialization hooks [datafusion]

Posted by "chakkk309 (via GitHub)" <gi...@apache.org>.
chakkk309 commented on PR #22550:
URL: https://github.com/apache/datafusion/pull/22550#issuecomment-4582311643

   > @chakkk309 can you please resolve conflicts?
   
   Done!


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] refactor: Port TryCastExpr proto serialization hooks [datafusion]

Posted by "chakkk309 (via GitHub)" <gi...@apache.org>.
chakkk309 commented on code in PR #22550:
URL: https://github.com/apache/datafusion/pull/22550#discussion_r3323077167


##########
datafusion/physical-expr/src/expressions/try_cast.rs:
##########
@@ -154,7 +217,20 @@ mod tests {
         },
         datatypes::*,
     };
+    #[cfg(feature = "proto")]
+    use datafusion_common::DataFusionError;
     use datafusion_physical_expr_common::physical_expr::fmt_sql;
+    #[cfg(feature = "proto")]
+    use datafusion_physical_expr_common::physical_expr::proto_decode::PhysicalExprDecodeCtx;
+    #[cfg(feature = "proto")]
+    use datafusion_physical_expr_common::physical_expr::proto_encode::PhysicalExprEncodeCtx;
+    #[cfg(feature = "proto")]
+    use datafusion_proto_models::protobuf::{self, physical_expr_node};
+
+    #[cfg(feature = "proto")]
+    use crate::proto_test_util::{
+        StubDecoder, StubEncoder, UnreachableDecoder, column_node,
+    };

Review Comment:
   Done, thanks! Already changed.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org