adriangb commented on code in PR #22532:
URL: https://github.com/apache/datafusion/pull/22532#discussion_r3318806173
##########
datafusion/physical-expr/src/expressions/is_not_null.rs:
##########
@@ -103,6 +102,60 @@ impl PhysicalExpr for IsNotNullExpr {
self.arg.fmt_sql(f)?;
write!(f, " IS NOT NULL")
}
+
+ #[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::IsNotNullExpr(
+ Box::new(protobuf::PhysicalIsNotNull {
+ expr: Some(Box::new(ctx.encode_child(&self.arg)?)),
+ }),
+ )),
+ }))
+ }
+}
+
+#[cfg(feature = "proto")]
+impl IsNotNullExpr {
+ /// Reconstruct an [`IsNotNullExpr`] from its protobuf representation.
+ ///
+ /// Takes the whole [`PhysicalExprNode`] — the exact inverse of what
+ /// [`PhysicalExpr::try_to_proto`] produces — so every expression's
+ /// `try_from_proto` shares one signature.
+ ///
+ /// [`PhysicalExprNode`]:
datafusion_proto_models::protobuf::PhysicalExprNode
+ /// [`PhysicalExpr::try_to_proto`]:
datafusion_physical_expr_common::physical_expr::PhysicalExpr::try_to_proto
+ /// [`PhysicalExprDecodeCtx::decode`]:
datafusion_physical_expr_common::physical_expr::proto_decode::PhysicalExprDecodeCtx::decode
+ 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_proto_models::protobuf;
+
+ let node = match &node.expr_type {
+ Some(protobuf::physical_expr_node::ExprType::IsNotNullExpr(node))
=> {
+ node.as_ref()
+ }
+ _ => {
+ return datafusion_common::internal_err!(
+ "PhysicalExprNode is not an IsNotNullExpr"
+ );
+ }
+ };
+ let expr = node.expr.as_deref().ok_or_else(|| {
+ datafusion_common::DataFusionError::Internal(
+ "IsNotNullExpr is missing required field 'expr'".to_string(),
+ )
+ })?;
Review Comment:
Please use the helpers on `PhysicalExprDecodeCtx`
##########
datafusion/physical-expr/src/expressions/is_not_null.rs:
##########
@@ -113,6 +166,8 @@ pub fn is_not_null(arg: Arc<dyn PhysicalExpr>) ->
Result<Arc<dyn PhysicalExpr>>
#[cfg(test)]
mod tests {
use super::*;
+ #[cfg(feature = "proto")]
+ use crate::expressions::Column;
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: [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]