Skip to content

Commit

Permalink
test(12733): reproducer of when metadata from the left side is not tr…
Browse files Browse the repository at this point in the history
…ansferred to the right side
  • Loading branch information
wiedld committed Oct 15, 2024
1 parent 5a0ea0b commit a9b6bd5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
25 changes: 20 additions & 5 deletions datafusion/sqllogictest/src/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,33 @@ pub async fn register_metadata_tables(ctx: &SessionContext) {
String::from("metadata_key"),
String::from("the l_name field"),
)]));

let schema = Schema::new(vec![id, name, l_name]).with_metadata(HashMap::from([(
String::from("metadata_key"),
String::from("the entire schema"),
)]));
let nonnull_name =
Field::new("nonnull_name", DataType::Utf8, false).with_metadata(HashMap::from([
(
String::from("metadata_key"),
String::from("the nonnull_name field"),
),
]));

let schema =
Schema::new(vec![id, name, l_name, nonnull_name]).with_metadata(HashMap::from([
(
String::from("metadata_key"),
String::from("the entire schema"),
),
]));

let batch = RecordBatch::try_new(
Arc::new(schema),
vec![
Arc::new(Int32Array::from(vec![Some(1), None, Some(3)])) as _,
Arc::new(StringArray::from(vec![None, Some("bar"), Some("baz")])) as _,
Arc::new(StringArray::from(vec![None, Some("l_bar"), Some("l_baz")])) as _,
Arc::new(StringArray::from(vec![
Some("no_foo"),
Some("no_bar"),
Some("no_baz"),
])) as _,
],
)
.unwrap();
Expand Down
9 changes: 9 additions & 0 deletions datafusion/sqllogictest/test_files/metadata.slt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ ORDER BY id, name, l_name;
NULL bar NULL
NULL NULL l_bar

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




statement ok
Expand Down

0 comments on commit a9b6bd5

Please sign in to comment.