Skip to content

Commit 2e02cc1

Browse files
committed
Add duplicate name error reproducer
1 parent 545c37f commit 2e02cc1

File tree

2 files changed

+196
-0
lines changed

2 files changed

+196
-0
lines changed

datafusion/substrait/tests/cases/logical_plans.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,29 @@ mod tests {
229229

230230
Ok(())
231231
}
232+
233+
#[tokio::test]
234+
async fn no_duplicate_unqualifed_name_union() -> Result<()> {
235+
let proto_plan =
236+
read_json("tests/testdata/test_plans/duplicate_name_in_union.substrait.json");
237+
let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto_plan)?;
238+
let plan = from_substrait_plan(&ctx.state(), &proto_plan).await?;
239+
240+
assert_snapshot!(
241+
plan,
242+
@r"
243+
Projection: foo AS col1, bar AS col2
244+
Union
245+
Projection: foo, bar
246+
Values: (Int64(100), Int64(200))
247+
Projection: x, foo
248+
Values: (Int32(300), Int64(400))
249+
"
250+
);
251+
252+
// Trigger execution to ensure plan validity
253+
DataFrame::new(ctx.state(), plan).show().await?;
254+
255+
Ok(())
256+
}
232257
}
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
{
2+
"version": {
3+
"minorNumber": 54,
4+
"producer": "datafusion-test"
5+
},
6+
"relations": [
7+
{
8+
"root": {
9+
"input": {
10+
"set": {
11+
"common": {
12+
"direct": {}
13+
},
14+
"inputs": [
15+
{
16+
"project": {
17+
"common": {
18+
"emit": {
19+
"outputMapping": [2, 3]
20+
}
21+
},
22+
"input": {
23+
"read": {
24+
"common": {
25+
"direct": {}
26+
},
27+
"baseSchema": {
28+
"names": ["foo", "bar"],
29+
"struct": {
30+
"types": [
31+
{
32+
"i64": {
33+
"nullability": "NULLABILITY_REQUIRED"
34+
}
35+
},
36+
{
37+
"i64": {
38+
"nullability": "NULLABILITY_REQUIRED"
39+
}
40+
}
41+
],
42+
"nullability": "NULLABILITY_REQUIRED"
43+
}
44+
},
45+
"virtualTable": {
46+
"expressions": [
47+
{
48+
"fields": [
49+
{
50+
"literal": {
51+
"i64": "100"
52+
}
53+
},
54+
{
55+
"literal": {
56+
"i64": "200"
57+
}
58+
}
59+
]
60+
}
61+
]
62+
}
63+
}
64+
},
65+
"expressions": [
66+
{
67+
"selection": {
68+
"directReference": {
69+
"structField": {
70+
"field": 0
71+
}
72+
},
73+
"rootReference": {}
74+
}
75+
},
76+
{
77+
"selection": {
78+
"directReference": {
79+
"structField": {
80+
"field": 1
81+
}
82+
},
83+
"rootReference": {}
84+
}
85+
}
86+
]
87+
}
88+
},
89+
{
90+
"project": {
91+
"common": {
92+
"emit": {
93+
"outputMapping": [2, 3]
94+
}
95+
},
96+
"input": {
97+
"read": {
98+
"common": {
99+
"direct": {}
100+
},
101+
"baseSchema": {
102+
"names": ["x", "foo"],
103+
"struct": {
104+
"types": [
105+
{
106+
"i32": {
107+
"nullability": "NULLABILITY_REQUIRED"
108+
}
109+
},
110+
{
111+
"i64": {
112+
"nullability": "NULLABILITY_REQUIRED"
113+
}
114+
}
115+
],
116+
"nullability": "NULLABILITY_REQUIRED"
117+
}
118+
},
119+
"virtualTable": {
120+
"expressions": [
121+
{
122+
"fields": [
123+
{
124+
"literal": {
125+
"i32": 300
126+
}
127+
},
128+
{
129+
"literal": {
130+
"i64": "400"
131+
}
132+
}
133+
]
134+
}
135+
]
136+
}
137+
}
138+
},
139+
"expressions": [
140+
{
141+
"selection": {
142+
"directReference": {
143+
"structField": {
144+
"field": 0
145+
}
146+
},
147+
"rootReference": {}
148+
}
149+
},
150+
{
151+
"selection": {
152+
"directReference": {
153+
"structField": {
154+
"field": 1
155+
}
156+
},
157+
"rootReference": {}
158+
}
159+
}
160+
]
161+
}
162+
}
163+
],
164+
"op": "SET_OP_UNION_ALL"
165+
}
166+
},
167+
"names": ["col1", "col2"]
168+
}
169+
}
170+
]
171+
}

0 commit comments

Comments
 (0)