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


##########
datafusion/proto/src/logical_plan/mod.rs:
##########
@@ -603,7 +603,7 @@ impl AsLogicalPlan for LogicalPlanNode {
                                 Arc::new(parquet)
                             }
                             #[cfg(not(feature = "parquet"))]
-                            panic!("Unable to process parquet file since 
`parquet` feature is not enabled");
+                            return not_impl_err!("Unable to process parquet 
file since `parquet` feature is not enabled");

Review Comment:
   Please add a library regression test using `logical_plan_from_bytes` that 
asserts `DataFusionError::NotImplemented` and the disabled Parquet diagnostic. 
Run it with `cargo test -p datafusion-proto --no-default-features --lib 
<test_name>` and report the result. Neither Avro test covers this branch.



##########
datafusion/proto/tests/cases/plans/sources.rs:
##########
@@ -1212,3 +1214,25 @@ fn 
roundtrip_parquet_exec_range_output_partitioning_utf8view_split_points() -> R
 
     Ok(())
 }
+
+/// Decoding an `AvroScan` node returns an error rather than panicking, with or
+/// without the `avro` feature.
+#[test]
+fn avro_scan_decode_returns_error() {
+    let node = PhysicalPlanNode {
+        physical_plan_type: Some(
+            protobuf::physical_plan_node::PhysicalPlanType::AvroScan(
+                protobuf::AvroScanExecNode::default(),
+            ),
+        ),
+    };
+    let ctx = SessionContext::new();
+    let err = node
+        .try_into_physical_plan(&ctx.task_ctx(), 
&DefaultPhysicalExtensionCodec {})

Review Comment:
   Optional: Could we use `physical_plan_from_bytes` with 
`node.encode_to_vec()` to exercise the public byte decoding API? The current 
converter test already catches the original panic.



##########
datafusion/proto/tests/cases/roundtrip_logical_plan.rs:
##########
@@ -643,6 +643,39 @@ async fn roundtrip_logical_plan_limit_skip() -> Result<()> 
{
     Ok(())
 }
 
+/// A listing scan in the Avro format decodes when the `avro` feature is
+/// enabled, and returns an error rather than panicking when it is not.
+#[tokio::test]
+async fn listing_scan_avro_format_decode() -> Result<()> {
+    let ctx = SessionContext::new();
+    ctx.register_csv("t1", "tests/testdata/test.csv", 
CsvReadOptions::default())
+        .await?;
+    let plan = ctx.table("t1").await?.into_optimized_plan()?;
+
+    let bytes = logical_plan_to_bytes(&plan)?;
+    let mut node = protobuf::LogicalPlanNode::decode(bytes.as_ref())
+        .map_err(|e| internal_datafusion_err!("{e}"))?;
+    let Some(protobuf::logical_plan_node::LogicalPlanType::ListingScan(scan)) =
+        node.logical_plan_type.as_mut()
+    else {
+        unreachable!("expected a ListingScan")
+    };
+    scan.file_format_type = Some(
+        
protobuf::listing_table_scan_node::FileFormatType::Avro(protobuf::AvroFormat 
{}),
+    );
+
+    let result = logical_plan_from_bytes(&node.encode_to_vec(), 
&ctx.task_ctx());
+    #[cfg(feature = "avro")]
+    result?;
+    #[cfg(not(feature = "avro"))]
+    datafusion_common::assert_contains!(

Review Comment:
   Optional: Could we assert that the decoded `ListingTable` exposes 
`AvroFormat` in `options().format`? Successful decoding alone does not verify 
format preservation.



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