radmirnovii opened a new pull request, #24490:
URL: https://github.com/apache/datafusion/pull/24490

   ## Which issue does this PR close?
   
   - Closes #24477.
   
   ## Rationale for this change
   
   See #24477.
   
   ## What changes are included in this PR?
   
   A simplifier rule generalizing the Eq/NotEq literal pushdown from #17743: an
   immutable scalar function whose single non-literal argument is a CASE with
   literal branch outputs is pushed into the branches, with each branch folded 
to
   a constant eagerly (reusing `ConstEvaluator`). If any branch fails to fold —
   including the materialized implicit-NULL ELSE — the expression is left
   untouched, preserving CASE's lazy-evaluation semantics. The function's own
   `simplify()` gets the first shot (required for `arrow_cast`-style functions).
   
   ## Are these changes tested?
   
   Yes: 14 unit tests beside the existing CASE rules, including an
   invocation-counting UDF proving the rewrite changes runtime behavior
   (8192 invocations per batch before; 2 plan-time, 0 runtime after), and
   negative tests for every guard: fold errors, mixed-type literals, literals
   with field metadata, volatile functions, non-literal branches/siblings, Cast.
   Benchmark numbers from #24489 will be added after it merges and this branch 
is
   rebased on it.
   
   ## Are there any user-facing changes?
   
   Plans containing `f(CASE-of-literals)` for immutable `f` now fold to a CASE
   over constants at plan time. No API changes.
   


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