shivadarshan-devadiga commented on PR #60756:
URL: https://github.com/apache/spark/pull/60756#issuecomment-7059465570

   Thanks @gengliangwang. I've reworked the PR along the lines of your design 
comment, and it addresses the other five comments too:
   - **During analysis.** A new type-coercion rule, 
`PadSetOperationCharLengths`, runs next to `WidenSetOperationTypes`. When the 
children of a `Union`, `Intersect` or `Except` have CHAR columns of different 
lengths, it pads the shorter children in a Project over each child, so the 
output, which comes from the first child, has the widest length. The 
single-pass resolver does the same in `SetOperationLikeResolver` with the same 
helper (`SetOperationCharPadding.padChildren`).
   - **Gate.** CHAR lengths of different sizes are the same `StringType`, so 
such a set operation would otherwise be resolved at once and the operators 
above it resolved with the first child's length. As with type widening, it now 
isn't resolved until its children are padded 
(`SetOperationCharPadding.isAligned`).
   - **Removed.** `mergeChildOutputs` no longer changes the metadata, and 
`padAtSource`, `withRawTypesOfInput` and the post-hoc set-operation padding are 
gone. What stays in `ApplyCharTypePadding` is narrowing views and recursive 
terms whose columns keep shorter lengths.
   
   One consequence I want to call out, since it reverses what I did for your 
earlier comment on DataFrame references: as with `WidenSetOperationTypes`, a 
padded first child now gives the set operation new attribute ids, so 
`a.union(b).select(a("c"))` fails to resolve when `a` is the shorter child, as 
it does today when `a`'s column is an INT and `b`'s a BIGINT. Your P0 here 
showed why the ids can't be kept: keeping them means changing the value where 
the column is produced, which every expression inside the child then sees. 
`a.union(b).select("c")` and references to the union's own columns work, and 
get the widest length.
   
   Can you please re-review?


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