You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handle name collisions for __datafusion_extracted aliases in leaf expression extraction #27944
Split out from #26969 as a follow-up (related to #25449, which tracks replacing the string-prefix protocol with a typed marker).
While #26969 fixes placement-based classification (is_extracted_alias) and canonical-ID seeding (extracted_expr_id), name collisions can still occur when user columns or aliases use the reserved __datafusion_extracted prefix:
Alias allocation collisions / wraparound: When existing __datafusion_extracted* names are near usize::MAX (causing AliasGenerator wraparound to _MAX / _0) or when PushDownLeafProjections runs without ExtractLeafExpressions, newly allocated extraction aliases can collide with existing column or alias names.
Input-column shadowing: When a projection aliases a pushdown-eligible expression to a __datafusion_extracted* name that already exists in its input schema (and the input column is also referenced), pushing that alias down directly causes an AmbiguousReference / duplicate field error:
CREATETABLEtASSELECT column1 AS __datafusion_extracted_manual, column2 AS s
FROMVALUES (0, {a: 1}), (1, {a: 2});
SELECT s['a'] AS __datafusion_extracted_manual
FROM t
WHEREt.__datafusion_extracted_manual>0;
Destination branch collisions (e.g., UNION ALL): Carrying a __datafusion_extracted* alias down across a set operation or join can collide with a column of the same name present only in another branch/side.
Expected behavior
Queries using columns or aliases with the __datafusion_extracted prefix should not fail with schema ambiguity errors, and collision avoidance should not regress leaf pushdown for ordinary queries (such as LEFT SEMI Parquet leaf pushdown).
Design notes
As discussed in #26969, adding ad-hoc destination checks at multiple sites duplicates merge-builder decisions and risks regressing unrelated pushdowns. Possible directions:
Handle collisions in a single place: reserve all existing __datafusion_extracted* names across the entire plan upfront, re-extract under a fresh plan-wide unique name instead of moving a potentially colliding alias down, and skip extraction instead of wrapping when no free name is available (verifying how this interacts with optimizer-generated aliases from earlier passes).
Activity