englefly commented on PR #69111: URL: https://github.com/apache/doris/pull/69111#issuecomment-6210818892
Robustness follow-up (`b8cd697f390`): the producer output correspondence is never guessed when the name is ambiguous. The name is not a key - a producer may output several columns with the same name (join of two tables which both have `k`, or a `GROUP BY t1.k, t2.k`). For outputs which keep their exprId the match is exact, but for renamed outputs the previous code took the first unmatched same-named candidate, which can pair the wrong slots if two same-named outputs are renamed in the same pass. Now: * an exprId which is still present means the output was not renamed, no mapping needed; * among the outputs which lost their exprId, take those with the same name - a **single** candidate is the renamed column; * several same-named candidates are narrowed by **lineage** (`originalTable`/`originalColumn`, which `Alias#toSlot` copies across a rename); if exactly one is left, it is the renamed column; * otherwise nothing is mapped: no candidate means the column was pruned by the body rewrite, and candidates which cannot be told apart are left as they are rather than mapped to a possibly wrong column (that is the previous behaviour, so no regression, and it never produces a wrong correspondence). `RewriteCteChildrenProducerRemapTest` covers the matching policy directly (the method is `@VisibleForTesting`): unchanged / renamed / pruned, same-named outputs matched by lineage **even when the new order is reversed** (the case a name-only match pairs wrongly), same-named outputs without lineage not guessed, and a renamed output whose same-named twin keeps its exprId. Rerun: RewriteCteChildrenProducerRemapTest 4/4, CteLimitPushdownPlanTest 10/10, DataTraitTest 14/14, ConstantPropagationTest 11/11, ConstantPropagationFreshExprIdTest 4/4, checkstyle passes. -- 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]
