kosiew commented on code in PR #27105:
URL: https://github.com/apache/datafusion/pull/27105#discussion_r4752610677


##########
datafusion/physical-plan/src/explain.rs:
##########
@@ -353,16 +353,17 @@ fn stringified_plan_from_proto(
         AnalyzedLogicalPlanType, OptimizedLogicalPlanType, 
OptimizedPhysicalPlanType,
     };
 
-    StringifiedPlan {
-        plan_type: match stringified_plan
-            .plan_type
-            .as_ref()
-            .and_then(|plan_type| plan_type.plan_type_enum.as_ref())
-            .unwrap_or_else(|| {
-                panic!(
-                    "Cannot create protobuf::StringifiedPlan from 
{stringified_plan:?}"
-                )
-            }) {
+    let plan_type_enum = stringified_plan
+        .plan_type
+        .as_ref()
+        .and_then(|plan_type| plan_type.plan_type_enum.as_ref())
+        .ok_or_else(|| {
+            datafusion_common::internal_datafusion_err!(
+                "ExplainExec is missing required field 'plan_type' of a 
'stringified_plans' entry"

Review Comment:
   Could we mention both 'plan_type' and its required 'plan_type_enum' variant 
in the error message? This would accurately describe both missing-field cases.



##########
datafusion/proto/tests/cases/plans/misc.rs:
##########
@@ -662,6 +694,55 @@ fn roundtrip_unnest() -> Result<()> {
     Ok(())
 }
 
+#[test]
+fn decode_unnest_exec_node_without_recursion_columns() -> Result<()> {
+    let codec = DefaultPhysicalExtensionCodec {};
+    let ctx = SessionContext::new();
+    let item = Field::new_list_field(DataType::Utf8, true);
+    let input_schema =
+        Arc::new(Schema::new(vec![Field::new_list("b", item.clone(), false)]));
+    let output_schema = Arc::new(Schema::new(vec![item.with_name("b")]));
+    let column = datafusion_common::Column::new_unqualified("b");
+    let unnest = UnnestExec::new(
+        Arc::new(EmptyExec::new(input_schema)),
+        vec![ListUnnest {
+            index_in_input_schema: 0,
+            depth: 1,
+        }],
+        vec![],
+        output_schema,
+        UnnestOptions {
+            null_handling: datafusion_common::NullHandling::Preserve,
+            recursions: vec![datafusion_common::RecursionUnnestOption {
+                input_column: column.clone(),
+                output_column: column,
+                depth: 1,
+            }],
+        },
+    )?;
+    let node = PhysicalPlanNode::try_from_physical_plan(Arc::new(unnest), 
&codec)?;
+
+    for field in ["input_column", "output_column"] {
+        let mut node = node.clone();
+        let 
Some(protobuf::physical_plan_node::PhysicalPlanType::Unnest(unnest)) =
+            node.physical_plan_type.as_mut()
+        else {
+            unreachable!("expected UnnestExecNode")
+        };
+        let recursion = &mut unnest.options.as_mut().unwrap().recursions[0];
+        match field {
+            "input_column" => recursion.input_column = None,
+            _ => recursion.output_column = None,
+        }
+        let error = node
+            .try_into_physical_plan(&ctx.task_ctx(), &codec)
+            .unwrap_err();
+        assert!(error.strip_backtrace().contains(&format!("'{field}'")));

Review Comment:
   Could we include the expected column name and actual error without its 
backtrace in the assertion message? This would make CI failures easier to 
diagnose.



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