Apache DataFusion SQL Query Engine
Add duplicate name error reproducer (#20106)
Gabriel1825f97b7669
diff --git a/datafusion/substrait/tests/cases/logical_plans.rs b/datafusion/substrait/tests/cases/logical_plans.rsindex 5ebacaf533..115c598430 100644--- a/datafusion/substrait/tests/cases/logical_plans.rs+++ b/datafusion/substrait/tests/cases/logical_plans.rs@@ -229,4 +229,31 @@ mod tests {Ok(())}++ #[tokio::test]+ // Test still failing, issue tracked in "https://github.com/apache/datafusion/issues/20123".+ #[ignore]+ async fn duplicate_name_in_union() -> Result<()> {+ let proto_plan =+ read_json("tests/testdata/test_plans/duplicate_name_in_union.substrait.json");+ let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto_plan)?;+ let plan = from_substrait_plan(&ctx.state(), &proto_plan).await?;++ assert_snapshot!(+ plan,+ @r"+ Projection: foo AS col1, bar AS col2+ Union+ Projection: foo, bar+ Values: (Int64(100), Int64(200))+ Projection: x, foo+ Values: (Int32(300), Int64(400))+ "+ );++ // Trigger execution to ensure plan validity+ DataFrame::new(ctx.state(), plan).show().await?;++ Ok(())+ }}diff --git a/datafusion/substrait/tests/testdata/test_plans/duplicate_name_in_union.substrait.json b/datafusion/substrait/tests/testdata/test_plans/duplicate_name_in_union.substrait.jsonnew file mode 100644index 0000000000..1da2ff6131--- /dev/null+++ b/datafusion/substrait/tests/testdata/test_plans/duplicate_name_in_union.substrait.json@@ -0,0 +1,171 @@+{+ "version": {+ "minorNumber": 54,+ "producer": "datafusion-test"+ },+ "relations": [+ {+ "root": {+ "input": {+ "set": {+ "common": {+ "direct": {}+ },+ "inputs": [+ {+ "project": {+ "common": {+ "emit": {+ "outputMapping": [2, 3]+ }+ },+ "input": {+ "read": {+ "common": {+ "direct": {}+ },+ "baseSchema": {+ "names": ["foo", "bar"],+ "struct": {+ "types": [+ {+ "i64": {+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "i64": {+ "nullability": "NULLABILITY_REQUIRED"+ }+ }+ ],+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "virtualTable": {+ "expressions": [+ {+ "fields": [+ {+ "literal": {+ "i64": "100"+ }+ },+ {+ "literal": {+ "i64": "200"+ }+ }+ ]+ }+ ]+ }+ }+ },+ "expressions": [+ {+ "selection": {+ "directReference": {+ "structField": {+ "field": 0+ }+ },+ "rootReference": {}+ }+ },+ {+ "selection": {+ "directReference": {+ "structField": {+ "field": 1+ }+ },+ "rootReference": {}+ }+ }+ ]+ }+ },+ {+ "project": {+ "common": {+ "emit": {+ "outputMapping": [2, 3]+ }+ },+ "input": {+ "read": {+ "common": {+ "direct": {}+ },+ "baseSchema": {+ "names": ["x", "foo"],+ "struct": {+ "types": [+ {+ "i32": {+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "i64": {+ "nullability": "NULLABILITY_REQUIRED"+ }+ }+ ],+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "virtualTable": {+ "expressions": [+ {+ "fields": [+ {+ "literal": {+ "i32": 300+ }+ },+ {+ "literal": {+ "i64": "400"+ }+ }+ ]+ }+ ]+ }+ }+ },+ "expressions": [+ {+ "selection": {+ "directReference": {+ "structField": {+ "field": 0+ }+ },+ "rootReference": {}+ }+ },+ {+ "selection": {+ "directReference": {+ "structField": {+ "field": 1+ }+ },+ "rootReference": {}+ }+ }+ ]+ }+ }+ ],+ "op": "SET_OP_UNION_ALL"+ }+ },+ "names": ["col1", "col2"]+ }+ }+ ]+}