Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix panic in avg aggregate and disable stddev by default #819

Merged
merged 4 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/user-guide/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The following Spark expressions are currently available. Any known compatibility
| ---------------- | ----- |
| UnaryMinus (`-`) | |

## Binary Arithmeticx
## Binary Arithmetic

| Expression | Notes |
| --------------- | --------------------------------------------------- |
Expand Down
4 changes: 0 additions & 4 deletions native/core/src/execution/datafusion/expressions/avg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,6 @@ where

// return arrays for sums and counts
fn state(&mut self, emit_to: EmitTo) -> Result<Vec<ArrayRef>> {
assert!(
matches!(emit_to, EmitTo::All),
"EmitTo::First is not supported"
);
let counts = emit_to.take_needed(&mut self.counts);
let counts = Int64Array::new(counts.into(), None);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,6 @@ impl GroupsAccumulator for AvgDecimalGroupsAccumulator {

// return arrays for sums and counts
fn state(&mut self, emit_to: EmitTo) -> Result<Vec<ArrayRef>> {
assert!(
matches!(emit_to, EmitTo::All),
"EmitTo::First is not supported"
);

let nulls = self.is_not_null.finish();
let nulls = Some(NullBuffer::new(nulls));

Expand Down
28 changes: 28 additions & 0 deletions spark/src/test/resources/tpcds-micro-benchmarks/agg_stddev.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.

select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
,stddev_samp(inv_quantity_on_hand) stdev
from inventory
,item
,warehouse
,date_dim
where inv_item_sk = i_item_sk
and inv_warehouse_sk = w_warehouse_sk
and inv_date_sk = d_date_sk
and d_year =2001
group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy;
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ object CometTPCDSMicroBenchmark extends CometTPCQueryBenchmarkBase {
"agg_low_cardinality",
"agg_sum_decimals_no_grouping",
"agg_sum_integers_no_grouping",
"agg_stddev",
"case_when_column_or_null",
"case_when_scalar",
"char_type",
Expand Down
Loading