shivadarshan-devadiga commented on PR #60756: URL: https://github.com/apache/spark/pull/60756#issuecomment-7040792470
Thanks @gengliangwang, all five were real. The first four come from the same mistake: the rule picked the widest length after resolution and then had to repair the metadata on every reference, and some references are out of its reach. I've redesigned the fix so that no repair pass is needed: - `Union.mergeChildOutputs` now gives the output the widest CHAR raw type when the children have CHAR columns or fields of different lengths at the same position. Every reference resolved against the union (a Project or Alias above it, a `CTERelationRef`, an `OuterReference`, an outer union) gets CHAR(max) at resolution time. `UnionLoop` keeps the old behaviour, because the anchor and the recursion aren't padded to the same length. - `ApplyCharTypePadding` now only pads the values of the shorter children, with `readSidePadding` (the same function the scan uses), which doesn't truncate over-length values. `transformUpWithNewOutput` still remaps the exprIds, and the metadata it keeps on the references is now already correct. There are new tests for each of your scenarios: a nested union with a CHAR(4) child that keeps 'abcde', a renamed column, a CTE referenced twice, a correlated `EXISTS` on `u.c`, and an over-length value in an external CHAR(2) table. They fail before this change and pass with it. Can you plese 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]
