Skip to content

Commit bc01392

Browse files
committed
refactor code
1 parent 88a770a commit bc01392

File tree

6 files changed

+12
-397
lines changed

6 files changed

+12
-397
lines changed

datafusion/core/tests/user_defined/user_defined_aggregates.rs

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ use datafusion_expr::{
4949
SimpleAggregateUDF,
5050
};
5151
use datafusion_physical_expr::expressions::AvgAccumulator;
52-
5352
/// Test to show the contents of the setup
5453
#[tokio::test]
5554
async fn test_setup() {

datafusion/functions-aggregate/src/approx_distinct.rs

-6
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,12 @@ impl Default for ApproxDistinct {
241241

242242
pub struct ApproxDistinct {
243243
signature: Signature,
244-
alias: Vec<String>,
245244
}
246245

247246
impl ApproxDistinct {
248247
pub fn new() -> Self {
249248
Self {
250249
signature: Signature::any(1, Volatility::Immutable),
251-
alias: vec![],
252250
}
253251
}
254252
}
@@ -303,8 +301,4 @@ impl AggregateUDFImpl for ApproxDistinct {
303301
};
304302
Ok(accumulator)
305303
}
306-
307-
fn aliases(&self) -> &[String] {
308-
&self.alias
309-
}
310304
}

datafusion/physical-expr/src/aggregate/build_in.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ use std::sync::Arc;
3030

3131
use arrow::datatypes::Schema;
3232

33-
use datafusion_common::{exec_err, not_impl_err, Result};
34-
use datafusion_expr::AggregateFunction;
35-
33+
use crate::aggregate::average::Avg;
3634
use crate::aggregate::regr::RegrType;
3735
use crate::expressions::{self, Literal};
3836
use crate::{AggregateExpr, PhysicalExpr, PhysicalSortExpr};
39-
37+
use datafusion_common::{exec_err, not_impl_err, Result};
38+
use datafusion_expr::AggregateFunction;
4039
/// Create a physical aggregation expression.
4140
/// This function errors when `input_phy_exprs`' can't be coerced to a valid argument type of the aggregation function.
4241
pub fn create_aggregate_expr(
@@ -146,11 +145,9 @@ pub fn create_aggregate_expr(
146145
name,
147146
data_type,
148147
)),
149-
(AggregateFunction::Avg, false) => Arc::new(expressions::Avg::new(
150-
input_phy_exprs[0].clone(),
151-
name,
152-
data_type,
153-
)),
148+
(AggregateFunction::Avg, false) => {
149+
Arc::new(Avg::new(input_phy_exprs[0].clone(), name, data_type))
150+
}
154151
(AggregateFunction::Avg, true) => {
155152
return not_impl_err!("AVG(DISTINCT) aggregations are not available");
156153
}

0 commit comments

Comments
 (0)