adriangb commented on code in PR #22463:
URL: https://github.com/apache/datafusion/pull/22463#discussion_r3320131782
##########
datafusion/physical-expr/src/expressions/not.rs:
##########
@@ -181,13 +183,111 @@ impl PhysicalExpr for NotExpr {
write!(f, "NOT ")?;
self.arg.fmt_sql(f)
}
+
+ #[cfg(feature = "proto")]
+ fn try_to_proto(
+ &self,
+ ctx:
&datafusion_physical_expr_common::physical_expr::proto_encode::PhysicalExprEncodeCtx<'_>,
+ ) -> Result<Option<datafusion_proto_models::protobuf::PhysicalExprNode>> {
+ use datafusion_proto_models::protobuf;
+
+ Ok(Some(protobuf::PhysicalExprNode {
+ expr_id: None,
+ expr_type:
Some(protobuf::physical_expr_node::ExprType::NotExpr(Box::new(
+ protobuf::PhysicalNot {
+ expr: Some(Box::new(ctx.encode_child(&self.arg)?)),
+ },
+ ))),
+ }))
+ }
+}
+
+#[cfg(feature = "proto")]
+impl NotExpr {
+ /// Reconstruct a [`NotExpr`] from its protobuf representation.
+ pub fn try_from_proto(
+ node: &datafusion_proto_models::protobuf::PhysicalExprNode,
+ ctx:
&datafusion_physical_expr_common::physical_expr::proto_decode::PhysicalExprDecodeCtx<'_>,
+ ) -> Result<Arc<dyn PhysicalExpr>> {
+ use datafusion_physical_expr_common::expect_expr_variant;
+ use datafusion_proto_models::protobuf;
+
+ let not_expr = expect_expr_variant!(
+ node,
+ protobuf::physical_expr_node::ExprType::NotExpr,
+ "NotExpr",
+ );
+ let expr = ctx
+ .decode_required_expression(not_expr.expr.as_deref(), "NotExpr",
"expr")
+ .map_err(|err| match err {
+ datafusion_common::DataFusionError::Internal(msg)
+ if msg.starts_with("NotExpr is missing required field
'expr'") =>
+ {
+ internal_datafusion_err!(
+ "NotExpr is missing required field 'expr' (expr_id:
{:?}, expr_type: {:?})",
+ node.expr_id,
+ &node.expr_type
+ )
+ }
+ other => other,
+ })?;
Review Comment:
yeah I don't think this is worth it:
https://github.com/apache/datafusion/pull/22463#discussion_r3320105797
--
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]