From 30f1a70d9c0333c911400603fbf6474d7fa333b5 Mon Sep 17 00:00:00 2001 From: wiedld Date: Fri, 27 Sep 2024 20:25:49 -0700 Subject: [PATCH 1/2] fix: do not drop metadata when From to arrow's Schema --- datafusion/common/src/dfschema.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/datafusion/common/src/dfschema.rs b/datafusion/common/src/dfschema.rs index 0dec14e9178a..715696b7c801 100644 --- a/datafusion/common/src/dfschema.rs +++ b/datafusion/common/src/dfschema.rs @@ -861,7 +861,10 @@ impl TryFrom for DFSchema { impl From for SchemaRef { fn from(df_schema: DFSchema) -> Self { - SchemaRef::new(df_schema.into()) + Arc::new(Schema::new_with_metadata( + df_schema.fields().to_owned(), + HashMap::new(), + )) } } From c15ef4780479e364398d4d40c2d7181495b4f1d7 Mon Sep 17 00:00:00 2001 From: wiedld Date: Fri, 27 Sep 2024 22:14:10 -0700 Subject: [PATCH 2/2] test: possible reproducer of issue 12560 --- datafusion/sqllogictest/test_files/metadata.slt | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/datafusion/sqllogictest/test_files/metadata.slt b/datafusion/sqllogictest/test_files/metadata.slt index 3b2b219244f5..d0aab4649f0a 100644 --- a/datafusion/sqllogictest/test_files/metadata.slt +++ b/datafusion/sqllogictest/test_files/metadata.slt @@ -31,18 +31,14 @@ select * from table_with_metadata; NULL bar 3 baz -query I rowsort +statement error DataFusion error: Internal error: Physical input schema should be the same as the one converted from logical input schema.. SELECT ( SELECT id FROM table_with_metadata ) UNION ( SELECT id FROM table_with_metadata ); ----- -1 -3 -NULL -query I rowsort +statement error DataFusion error: Internal error: Physical input schema should be the same as the one converted from logical input schema.. SELECT "data"."id" FROM ( @@ -54,9 +50,6 @@ FROM SELECT "id" FROM "table_with_metadata" ) as "samples" WHERE "data"."id" = "samples"."id"; ----- -1 -3 statement ok drop table table_with_metadata;