adriangb commented on code in PR #23915:
URL: https://github.com/apache/datafusion/pull/23915#discussion_r3682667646
##########
datafusion/physical-plan/src/proto.rs:
##########
@@ -102,6 +103,14 @@ pub trait ExecutionPlanDecode {
/// deserializer, so the child's own `try_from_proto` is honored).
fn decode_plan(&self, node: &PhysicalPlanNode) -> Result<Arc<dyn
ExecutionPlan>>;
+ /// Deserialize a child plan with `results` active for scalar subquery
+ /// expressions in that plan's subtree.
+ fn decode_plan_with_scalar_subquery_results(
Review Comment:
It'd be nice to seal this trait. I'll make a PR.
##########
datafusion/physical-plan/src/scalar_subquery.rs:
##########
@@ -254,6 +254,68 @@ impl ExecutionPlan for ScalarSubqueryExec {
fn cardinality_effect(&self) -> CardinalityEffect {
CardinalityEffect::Equal
}
+
+ #[cfg(feature = "proto")]
+ fn try_to_proto(
+ &self,
+ ctx: &crate::proto::ExecutionPlanEncodeCtx<'_>,
+ ) -> Result<Option<datafusion_proto_models::protobuf::PhysicalPlanNode>> {
+ use datafusion_proto_models::protobuf;
+
+ let input = ctx.encode_child(self.input())?;
+ // Subquery indices are positional and recovered during decoding.
+ let subqueries =
+ ctx.encode_children(self.subqueries().iter().map(|subquery|
&subquery.plan))?;
+ Ok(Some(protobuf::PhysicalPlanNode {
+ physical_plan_type: Some(
+
protobuf::physical_plan_node::PhysicalPlanType::ScalarSubquery(Box::new(
+ protobuf::ScalarSubqueryExecNode {
+ input: Some(Box::new(input)),
+ subqueries,
+ },
+ )),
+ ),
+ }))
+ }
+}
+
+#[cfg(feature = "proto")]
+impl ScalarSubqueryExec {
+ /// Reconstruct a [`ScalarSubqueryExec`] from its protobuf representation.
+ pub fn try_from_proto(
+ node: &datafusion_proto_models::protobuf::PhysicalPlanNode,
+ ctx: &crate::proto::ExecutionPlanDecodeCtx<'_>,
+ ) -> Result<Arc<dyn ExecutionPlan>> {
+ use datafusion_proto_models::protobuf;
+
+ let scalar_subquery = crate::expect_plan_variant!(
+ node,
+ protobuf::physical_plan_node::PhysicalPlanType::ScalarSubquery,
+ "ScalarSubqueryExec",
+ );
+ let results =
ScalarSubqueryResults::new(scalar_subquery.subqueries.len());
+ let input_node = scalar_subquery.input.as_deref().ok_or_else(|| {
+ datafusion_common::internal_datafusion_err!(
+ "ScalarSubqueryExec is missing required field 'input'"
+ )
+ })?;
Review Comment:
```suggestion
let input_node = ctx.decode_required_child(
scalar_subquery.input.as_deref(),
"ScalarSubqueryExec",
"input"
)?;
```
--
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]