kosiew commented on code in PR #25478:
URL: https://github.com/apache/datafusion/pull/25478#discussion_r4204944883


##########
datafusion/sqllogictest/test_files/struct.slt:
##########
@@ -1890,3 +1890,78 @@ from (values (1),(2),(1)) group by 1;
 ----
 {a: 1, z: NULL} 2
 {a: 2, z: NULL} 1
+
+# A sub-query projection that renames a column to the name of a different
+# column of the same input, with a struct field read above it. Leaf projection
+# pushdown resolved the parent's column references through the rename map and
+# added the renamed input column a second time, which made the output schema
+# ambiguous (https://github.com/apache/datafusion/issues/25446).
+statement ok
+create table rename_swap_struct(a int, b int, s struct<x varchar>) as values 
(1, 10, {x: 'p'}), (2, 20, {x: 'q'});
+
+# a rename beside a same-name alias, under a filter
+query IIT
+select b, a, s['x'] from (select rename_swap_struct.a as b, 
rename_swap_struct.b as a, s from rename_swap_struct) where a > 0 order by b;

Review Comment:
   Optional: could we change this to `where a > 15` and expect only `2 20 q`? 
The current `a > 0` case passes with either possible binding because both 
source columns are positive, while `a > 15` would also verify the alias binding 
at the result level.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to