kosiew commented on code in PR #24775:
URL: https://github.com/apache/datafusion/pull/24775#discussion_r3912248573
##########
datafusion/physical-expr/src/expressions/lambda.rs:
##########
@@ -496,3 +509,148 @@ mod tests {
);
}
}
+
+/// Tests for the `try_to_proto` / `try_from_proto` hooks.
+#[cfg(all(test, feature = "proto"))]
+mod proto_tests {
+ use super::*;
+ use crate::proto_test_util::{
+ StubDecoder, StubEncoder, UnreachableDecoder, column_node,
+ };
+ use arrow::datatypes::Field;
+ use datafusion_common::DataFusionError;
+ use
datafusion_physical_expr_common::physical_expr::proto_decode::PhysicalExprDecodeCtx;
+ use
datafusion_physical_expr_common::physical_expr::proto_encode::PhysicalExprEncodeCtx;
+ use datafusion_proto_models::protobuf::{self, PhysicalExprNode};
+
+ /// A one-parameter lambda whose body references that parameter.
+ fn proto_lambda_fixture() -> LambdaExpr {
+ let v_field = Arc::new(Field::new("v", DataType::Int32, true));
+ LambdaExpr::try_new(
+ vec!["v".to_string()],
+ Arc::new(LambdaVariable::new(0, v_field)),
+ )
+ .unwrap()
+ }
+
+ fn proto_lambda_node(
+ params: Vec<String>,
+ body: Option<Box<PhysicalExprNode>>,
+ ) -> PhysicalExprNode {
+ PhysicalExprNode {
+ expr_id: None,
+ expr_type:
Some(protobuf::physical_expr_node::ExprType::Lambda(Box::new(
+ protobuf::PhysicalLambdaExprNode { params, body },
+ ))),
+ }
+ }
+
+ #[test]
+ fn try_to_proto_encodes_lambda() {
Review Comment:
Could you consider adding one end-to-end nested lambda and lambda-variable
proto roundtrip using the real encoder/decoder dispatch? The new unit tests do
a good job of testing each hook in isolation, but since they use stubs they do
not exercise the dispatcher path that connects these two variants. This is
non-blocking, and the existing targeted hook and error coverage already looks
good.
--
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]