alexanderbianchi opened a new pull request, #27573: URL: https://github.com/apache/datafusion/pull/27573
## Which issue does this PR close? No separate issue for this reproducer. Related to #16063. ## Rationale for this change A valid query fails physical planning after a Substrait round trip when a limited UNION branch contains columns with the same name: ```sql (SELECT * FROM (VALUES (1)) AS x(a) CROSS JOIN (VALUES (2)) AS y(a) LIMIT 1) UNION ALL SELECT * FROM (VALUES (3)) AS x(a) CROSS JOIN (VALUES (4)) AS y(a); ``` The round trip fails with `Input field name column1 does not match with the projection expression column1_1`, instead of returning `(1, 2)` and `(3, 4)`. ## What changes are included in this PR? UNION type coercion already aligns Projection inputs with the UNION's output names. When an input is wrapped in LIMIT and needs no casts, it skips that alignment. The logical UNION then advertises deduplicated names while its physical input retains the original names. Align non-Projection inputs with the UNION schema when their field names differ, using the existing projection helper. Add the minimal regression to `limit.slt` and update two expected plans for the resulting aliases. ## What is the testing strategy for this PR? The new `limit.slt` case passes as ordinary SQL and through Substrait; it reproduces the assertion without the fix. This file is already included in CI's Substrait round-trip coverage. - Extended workspace tests, including all 307 SQL test files. - Both Substrait round-trip modes. - Workspace Clippy with all targets/features and warnings denied; formatting checks. ## Are there any user-facing changes? Affected Substrait plans now execute successfully. No public API changes. Developed with Codex assistance. -- 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]
