Copilot commented on code in PR #22464:
URL: https://github.com/apache/datafusion/pull/22464#discussion_r3290035448


##########
datafusion/physical-expr/src/expressions/unknown_column.rs:
##########
@@ -84,6 +87,36 @@ impl PhysicalExpr for UnKnownColumn {
     fn fmt_sql(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self, f)
     }
+
+    #[cfg(feature = "proto")]
+    fn try_to_proto(
+        &self,
+        _ctx: 
&datafusion_physical_expr_common::physical_expr::proto_encode::PhysicalExprEncodeCtx<'_>,
+    ) -> Result<Option<protobuf::PhysicalExprNode>> {
+        Ok(Some(protobuf::PhysicalExprNode {
+            expr_id: None,
+            expr_type: 
Some(protobuf::physical_expr_node::ExprType::UnknownColumn(
+                protobuf::UnknownColumn {
+                    name: self.name.clone(),
+                },
+            )),
+        }))

Review Comment:
   `try_to_proto` is constructing a `PhysicalExprNode` with `expr_id: None`, 
while the previous inlined serialization path in `to_proto.rs` populated 
`expr_id` from the serializer’s `expr_id` variable. If `expr_id` is required 
for stable hashing/dedup/references in the proto encoding, this will change 
behavior and can break round-trips. Consider using the provided encode context 
(`ctx`) to assign/populate `expr_id` consistently with other expressions (or 
ensure the caller overwrites `expr_id` after `try_to_proto` returns).



##########
datafusion/physical-expr/src/expressions/unknown_column.rs:
##########
@@ -84,6 +87,36 @@ impl PhysicalExpr for UnKnownColumn {
     fn fmt_sql(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         std::fmt::Display::fmt(self, f)
     }
+
+    #[cfg(feature = "proto")]
+    fn try_to_proto(
+        &self,
+        _ctx: 
&datafusion_physical_expr_common::physical_expr::proto_encode::PhysicalExprEncodeCtx<'_>,
+    ) -> Result<Option<protobuf::PhysicalExprNode>> {
+        Ok(Some(protobuf::PhysicalExprNode {
+            expr_id: None,
+            expr_type: 
Some(protobuf::physical_expr_node::ExprType::UnknownColumn(
+                protobuf::UnknownColumn {
+                    name: self.name.clone(),
+                },
+            )),
+        }))
+    }
+}
+
+#[cfg(feature = "proto")]
+impl UnKnownColumn {
+    /// Reconstruct an [`UnKnownColumn`] from its protobuf representation.
+    pub fn try_from_proto(
+        node: &protobuf::PhysicalExprNode,
+        _ctx: 
&datafusion_physical_expr_common::physical_expr::proto_decode::PhysicalExprDecodeCtx<'_>,
+    ) -> Result<Arc<dyn PhysicalExpr>> {
+        let protobuf::UnknownColumn { name } = match &node.expr_type {
+            Some(protobuf::physical_expr_node::ExprType::UnknownColumn(c)) => 
c,
+            _ => return internal_err!("PhysicalExprNode is not an 
UnKnownColumn"),
+        };

Review Comment:
   The error message is a bit generic for debugging proto decode failures. 
Consider including the actual `expr_type` (and/or `expr_id`) in the error so 
callers can diagnose mismatched nodes more easily (e.g., report which variant 
was found).



-- 
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]

Reply via email to