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(), + )) } } 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;