Skip to content

Commit

Permalink
Fix ApproxPercentileAccumulator
Browse files Browse the repository at this point in the history
  • Loading branch information
Dandandan committed Mar 12, 2024
1 parent bd9a272 commit 21c3a11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ impl Accumulator for ApproxPercentileAccumulator {

fn evaluate(&mut self) -> Result<ScalarValue> {
if self.digest.count() == 0.0 {
return exec_err!("aggregate function needs at least one non-null element");
return Ok(ScalarValue::Null);
}
let q = self.digest.estimate_quantile(self.percentile);

Expand Down
5 changes: 3 additions & 2 deletions datafusion/sqllogictest/test_files/aggregate.slt
Original file line number Diff line number Diff line change
Expand Up @@ -2255,9 +2255,10 @@ select median(a) from (select 1 as a where 1=0);
----
NULL

query error DataFusion error: Execution error: aggregate function needs at least one non-null element
query I
select approx_median(a) from (select 1 as a where 1=0);

----
NULL

# aggregate_decimal_sum
query RT
Expand Down

0 comments on commit 21c3a11

Please sign in to comment.