dd-annarose opened a new pull request, #25337:
URL: https://github.com/apache/datafusion/pull/25337

   ## Which issue does this PR close?
   
   - Closes #24337.
   
   ## Rationale for this change
   
   When using a projection as the percentile argument to 
`approx_percentile_cont` or `percentile_cont`, planning fails because only 
literals are supported.
   
   It makes sense to accept projections that are constant across all batches 
but not labelled as literals (although they practically are).
   
   For example, this query cannot be planned, even though the percentile is 
constant:
   
   ```
   SELECT
       approx_percentile_cont(y, m) AS median
   FROM (
       SELECT t.x + 1 as y, 0.5 as m
       FROM (
           VALUES (10)
       ) AS t(x)
   )
   ```
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here, but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   Introduce `PercentileParam` and `PercentileParamState` to handle column 
references or projections for the percentile argument.
   
   Resolution of `percentile` cannot always be done: for example, on an empty 
record batch, we won't be able to get the value from the columns. 
`PercentileParamState` makes sure the percentile resolution is both flexible 
enough to wait to be able to resolve the parameter AND applies the strict 
constraints that are required (constant `Float32` or `Float64`).
   
   The percentile is also included in state fields so that the merge_batch in 
the final Accumulator can process without any issues.
   
   ## What is the testing strategy for this PR?
   
   This new feature is covered by the `sqllogictest` cases added in 
`aggregate.slt`.
   
   Unit tests have also been added to `approx_percentile_cont.rs` and 
`percentile_cont.rs`.
   
   ## Are there any user-facing changes?
   
   No breaking 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