Skip to content

Commit d8a6809

Browse files
gabotechsdd-david-levin
authored andcommitted
Add duplicate name error reproducer (apache#20106)
<!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Closes #. <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> Reproduces a duplicate name issue introduced in apache#19019. Reverting the following code: https://github.com/apache/datafusion/blob/2e02cc131d1d71cce819000912f0411345ca2d6e/datafusion/expr/src/expr_rewriter/mod.rs#L263-L263 From: ```rust _ => { // maintain the original name when casting let name = dst_schema.field(idx).name(); Ok(expr.cast_to(new_type, src_schema)?.alias(name)) } ``` to ```rust _ => expr.cast_to(new_type, src_schema), ``` Seems to fix the issue. TODO: actually fix the issue before merging <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> For now, just a reproducer test <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> yes, by a new test no <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> (cherry picked from commit 1825f97)
1 parent 9723464 commit d8a6809

1 file changed

Lines changed: 171 additions & 0 deletions

File tree

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)