Skip to content

Commit a9b6bd5

Browse files
author
wiedld
committed
test(12733): reproducer of when metadata from the left side is not transferred to the right side
1 parent 5a0ea0b commit a9b6bd5

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

datafusion/sqllogictest/src/test_context.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,18 +319,33 @@ pub async fn register_metadata_tables(ctx: &SessionContext) {
319319
String::from("metadata_key"),
320320
String::from("the l_name field"),
321321
)]));
322-
323-
let schema = Schema::new(vec![id, name, l_name]).with_metadata(HashMap::from([(
324-
String::from("metadata_key"),
325-
String::from("the entire schema"),
326-
)]));
322+
let nonnull_name =
323+
Field::new("nonnull_name", DataType::Utf8, false).with_metadata(HashMap::from([
324+
(
325+
String::from("metadata_key"),
326+
String::from("the nonnull_name field"),
327+
),
328+
]));
329+
330+
let schema =
331+
Schema::new(vec![id, name, l_name, nonnull_name]).with_metadata(HashMap::from([
332+
(
333+
String::from("metadata_key"),
334+
String::from("the entire schema"),
335+
),
336+
]));
327337

328338
let batch = RecordBatch::try_new(
329339
Arc::new(schema),
330340
vec![
331341
Arc::new(Int32Array::from(vec![Some(1), None, Some(3)])) as _,
332342
Arc::new(StringArray::from(vec![None, Some("bar"), Some("baz")])) as _,
333343
Arc::new(StringArray::from(vec![None, Some("l_bar"), Some("l_baz")])) as _,
344+
Arc::new(StringArray::from(vec![
345+
Some("no_foo"),
346+
Some("no_bar"),
347+
Some("no_baz"),
348+
])) as _,
334349
],
335350
)
336351
.unwrap();

datafusion/sqllogictest/test_files/metadata.slt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ ORDER BY id, name, l_name;
123123
NULL bar NULL
124124
NULL NULL l_bar
125125

126+
# Regression test: missing field metadata from left side of the union when right side is chosen
127+
statement error DataFusion error: Internal error: Physical input schema should be the same as the one converted from logical input schema..
128+
select name from (
129+
SELECT nonnull_name as name FROM "table_with_metadata"
130+
UNION ALL
131+
SELECT NULL::string as name
132+
) group by name order by name;
133+
134+
126135

127136

128137
statement ok

0 commit comments

Comments
 (0)