Skip to content

Commit b1c9fa2

Browse files
adriangbclaude
andcommitted
fix(optimizer): do not re-inline a shared definition in leaf extraction
`ExtractLeafExpressions` and `PushDownLeafProjections` merge an extracted field access into an input projection, and resolve its column references to the definitions of that projection. When `CommonSubexprEliminate` made the column for a struct-returning UDF, the merge puts a copy of the UDF call next to the original, so the plan evaluates it two times: Filter: CASE WHEN __common_expr_1 IS NOT NULL THEN __datafusion_extracted_2 IS NULL END Projection: arrow_field(t.a) AS __common_expr_1, t.a, get_field(arrow_field(t.a), 'nullable') AS __datafusion_extracted_2 Delete `would_duplicate_volatile`, `merge_would_duplicate_kept_expr` and `build_projection_replace_map`, and use `ProjectionInliner` at every merge site. The inliner counts the evaluations over the extracted expressions and over the columns that the nodes above reference directly, so it also sees the reference sites that `merge_would_duplicate_kept_expr` could not see: they are in a different node. Closes apache#25329 Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 0f9fb4c commit b1c9fa2

1 file changed

Lines changed: 315 additions & 258 deletions

File tree

0 commit comments

Comments
 (0)