adriangb commented on code in PR #24628:
URL: https://github.com/apache/datafusion/pull/24628#discussion_r3846260689
##########
datafusion/physical-expr-common/src/physical_expr.rs:
##########
@@ -781,9 +884,156 @@ pub mod proto_decode {
})
}
+ /// Reconstructs one extension expression from its proto node, as stored
+ /// in a [`PhysicalExprDecoderRegistry`].
+ ///
+ /// A plain `fn` pointer, since the natural implementation is an inherent
+ /// associated function on the expression returning `Arc<dyn PhysicalExpr>`
+ /// — the same shape the built-in expressions' `try_from_proto` already
has,
+ /// so there is no `Self`-return object-safety problem to work around:
+ ///
+ /// ```ignore
+ /// impl MyExpr {
+ /// const EXPR_NAME: &'static str = "my_crate.MyExpr";
+ ///
+ /// fn try_from_proto(
+ /// node: &PhysicalExprNode,
+ /// ctx: &PhysicalExprDecodeCtx<'_>,
+ /// ) -> Result<Arc<dyn PhysicalExpr>> {
+ /// let extension = expect_expr_variant!(
+ /// node,
+ /// physical_expr_node::ExprType::Extension,
+ /// "Extension",
+ /// );
+ /// let payload = MyExprProto::decode(extension.expr.as_slice())?;
+ /// let children =
ctx.decode_children_expressions(&extension.inputs)?;
+ /// Ok(Arc::new(MyExpr::new(payload, children)))
+ /// }
+ /// }
+ /// ```
+ pub type PhysicalExprDecoderFn = fn(
+ &PhysicalExprNode,
+ &PhysicalExprDecodeCtx<'_>,
+ ) -> Result<Arc<dyn PhysicalExpr>>;
Review Comment:
Should this be a method on `PhysicalExpr` like `to_proto`?
--
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]