kosiew commented on PR #26969:
URL: https://github.com/apache/datafusion/pull/26969#issuecomment-7304392262

   @mattsu2020 
   
   Thanks for working through all the review rounds. Looking at the whole 
change, I think it contains two separate fixes that would be easier to review 
and land apart, and the slow progress is partly my fault.
   
   **1. Classifying by placement fixes a real user-facing bug.** `SELECT 10 / 
id AS __datafusion_extracted_manual FROM t WHERE id > 0` should never divide by 
zero. `is_extracted_alias` fixes this where the decision belongs: whether an 
expression may be evaluated below a guard now comes from `Expr::placement`, not 
from its alias text. The narrower `extracted_expr_id` keeps invalid suffixes 
from moving the counter. Together with the guarded-division SQL and Rust tests, 
this part is small and correct, and I'd be glad to approve it alone.
   
   **2. Avoiding name collisions is a different problem.** It only shows up 
when user columns or aliases use the reserved `__datafusion_extracted` prefix, 
often with suffixes near `usize::MAX`. Each review round, including my own 
requests, found one more place where a moved name could collide. The PR added a 
check at each one: reserved-name sets, re-extraction on shadowing, 
`has_destination_alias_conflict` at three sites, and a join-only check. The 
latest round showed that the join check now blocks Parquet leaf pushdown for an 
ordinary `LEFT SEMI` shape. `has_destination_alias_conflict` also repeats the 
merge builder's decisions, so the two have to stay in sync. The underlying 
cause is still that we can't tell generated aliases from user ones, which is 
#25449, and the description says full disambiguation still depends on it.
   
   I don't think more checks at more sites will settle this, and my 
crafted-name witnesses pushed the PR that way. So I suggest:
   
   - **This PR:** keep only the placement classification and the canonical-ID 
seeding, roughly `a8d5031b26` and `b706ae6fec` without the wraparound and 
collision tests, plus the guarded-division tests. Drop the allocation, 
shadowing and destination-check changes.
   - **Collisions:** track them separately, either as a documented limitation 
of the reserved prefix until #25449 lands, or as a follow-up that handles 
collisions in one place. One idea I haven't tried: never move a user-supplied 
prefixed alias down the plan, always re-extract under a fresh name reserved 
across the whole plan, and skip the extraction instead of wrapping when no name 
is free. I haven't checked whether that holds for aliases the optimizer 
generated on an earlier pass, so please treat it as a starting point for 
discussion, not a requirement.
   
   Sorry for the churn. Splitting it this way lets the real fix merge now and 
leaves the collision design to its own discussion.
   


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