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

   
   ## Which issue does this PR close?
   
   - Refs #16453
   
   This partially addresses #16453 by supporting the `window_start()` / 
`window_end()` style zero-argument aggregate UDF workaround discussed in the 
issue thread. It does not implement projection of non-table virtual columns 
such as `SELECT window_start, window_end, ...`.
   
   ## Rationale for this change
   
   DataFusion already rewrites SQL `count()` / `count(*)` to a physical count 
over `COUNT_STAR_EXPANSION`, but user-defined aggregate functions with explicit 
nullary signatures could not reliably flow through planning and physical 
execution. This blocked using aggregate metadata functions that naturally take 
no input arguments.
   
   ## What changes are included in this PR?
   
   - Allow physical aggregate expressions with empty argument lists when the 
UDAF signature supports `TypeSignature::Nullary`.
   - Keep direct empty physical `count` construction rejected, so callers must 
use the existing `COUNT_STAR_EXPANSION` representation for `count(*)`.
   - Support nullary UDAFs through no-group, grouped, filtered, and 
adapter-backed aggregate execution paths.
   - Disable row-to-state conversion for adapter-backed nullary aggregates 
because there is no value array to provide input row cardinality.
   
   ## Are these changes tested?
   
   Yes. Added coverage for:
   
   - SQL planning of a nullary aggregate UDF.
   - No-group execution of a nullary aggregate UDF.
   - No-group nullary aggregate UDF with a filter that removes all rows.
   - Grouped execution of a nullary aggregate UDF.
   - Direct physical empty-argument `count` construction returning a planning 
error.
   
   Local checks run:
   
   - `cargo fmt --all -- --check`
   - `cargo test -p datafusion-functions-aggregate-common groups_accumulator`
   - `cargo test -p datafusion --test user_defined_integration 
test_zero_argument_udaf`
   - `cargo test -p datafusion-physical-plan count_requires_physical_argument`
   - `cargo test -p datafusion-sql --test sql_integration 
plan_zero_argument_aggregate_udf`
   - `cargo clippy --all-targets --all-features -- -D warnings`
   
   ## Are there any user-facing changes?
   
   Yes. DataFusion can now plan and execute aggregate UDFs declared with 
`Signature::nullary(...)`, including grouped and filtered aggregate queries.
   


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