Subodh-17 commented on PR #27612:
URL: https://github.com/apache/datafusion/pull/27612#issuecomment-7061132687

   Thanks @Adam-Alani, this looks like a solid fix that completes the 
positional alignment for multi-input unions following the empty-input 
elimination.
   
   I independently reproduced the issue against unpatched `main`. When 
`PropagateEmptyRelation` removes the empty first input, the Union retains its 
original schema names, while the surviving inputs may retain different names.
   
   The failure is particularly visible when the branches aren't bare 
projections—for example, branches containing `LIMIT`—where analyzer 
`TypeCoercion` doesn't pre-alias the inputs. An outer expression such as 
`SELECT a + 1 FROM (...)` then triggers the physical planning assertion:
   
   ```text
   Internal error: Assertion failed: col.name() == matching_name:
   Input field name b does not match with the projection expression a.
   ```
   
   Without an outer expression, I also observed the output schema drifting to 
the surviving input's name.
   
   With this PR's `align_union_input` logic, I verified that both the assertion 
and schema mismatch are resolved.
   
   One minor test observation: the added bare-projection SQL example can be 
masked by `TypeCoercion::coerce_union` on unpatched `main`. A branch with 
`LIMIT`, or an outer expression, makes the reproduction more direct. The 
optimizer unit test already covers the rule itself, so this is only a possible 
integration-test improvement.
   
   Thanks for addressing this edge case.
   


-- 
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