Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Runji Wang <[email protected]>
  • Loading branch information
wangrunji0408 committed May 21, 2024
1 parent a17a70d commit 873ee7b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/batch/benches/hash_agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fn create_agg_call(
order_by: vec![],
filter: None,
direct_args: vec![],
udf: None,
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/expr/core/src/aggregate/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,7 @@ impl AggArgs {
val_indices: args.iter().map(|arg| arg.get_index() as usize).collect(),
})
}
}

impl AggArgs {
/// return the types of arguments.
pub fn arg_types(&self) -> &[DataType] {
&self.data_types
Expand All @@ -510,3 +508,13 @@ impl AggArgs {
&self.val_indices
}
}

impl FromIterator<(DataType, usize)> for AggArgs {
fn from_iter<T: IntoIterator<Item = (DataType, usize)>>(iter: T) -> Self {
let (data_types, val_indices): (Vec<_>, Vec<_>) = iter.into_iter().unzip();
AggArgs {
data_types: data_types.into(),
val_indices: val_indices.into(),
}
}
}
30 changes: 11 additions & 19 deletions src/expr/impl/benches/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use criterion::{criterion_group, criterion_main, Criterion};
use risingwave_common::array::*;
use risingwave_common::types::test_utils::IntervalTestExt;
use risingwave_common::types::*;
use risingwave_expr::aggregate::{build_append_only, AggArgs, AggCall, AggKind};
use risingwave_expr::aggregate::{build_append_only, AggCall, AggKind};
use risingwave_expr::expr::*;
use risingwave_expr::sig::FUNCTION_REGISTRY;
use risingwave_pb::expr::expr_node::PbType;
Expand Down Expand Up @@ -396,26 +396,17 @@ fn bench_expr(c: &mut Criterion) {
}
let agg = match build_append_only(&AggCall {
kind: sig.name.as_aggregate(),
args: match sig.inputs_type.as_slice() {
[] => AggArgs::None,
[t] => AggArgs::Unary(t.as_exact().clone(), input_index_for_type(t.as_exact())),
[t1, t2] => AggArgs::Binary(
[t1.as_exact().clone(), t2.as_exact().clone()],
[
input_index_for_type(t1.as_exact()),
input_index_for_type(t2.as_exact()),
],
),
_ => {
println!("todo: {sig:?}");
continue;
}
},
args: sig
.inputs_type
.iter()
.map(|t| (t.as_exact().clone(), input_index_for_type(t.as_exact())))
.collect(),
return_type: sig.ret_type.as_exact().clone(),
column_orders: vec![],
filter: None,
distinct: false,
direct_args: vec![],
user_defined: None,
}) {
Ok(agg) => agg,
Err(e) => {
Expand All @@ -433,9 +424,10 @@ fn bench_expr(c: &mut Criterion) {
_ => unreachable!(),
};
c.bench_function(&format!("{sig:?}"), |bencher| {
bencher
.to_async(FuturesExecutor)
.iter(|| async { agg.update(&mut agg.create_state(), &input).await.unwrap() })
bencher.to_async(FuturesExecutor).iter(|| async {
let mut state = agg.create_state().unwrap();
agg.update(&mut state, &input).await.unwrap()
})
});
}
}
Expand Down
1 change: 1 addition & 0 deletions src/meta/src/stream/test_fragmenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ fn make_sum_aggcall(idx: u32) -> AggCall {
order_by: vec![],
filter: None,
direct_args: vec![],
udf: None,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/sqlparser/tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ fn parse_create_aggregate() {
or_replace: true,
name: ObjectName(vec![Ident::new_unchecked("sum")]),
args: vec![OperateFunctionArg::unnamed(DataType::Int)],
returns: Some(DataType::BigInt),
returns: DataType::BigInt,
append_only: true,
params: CreateFunctionBody {
language: Some("python".into()),
Expand Down
6 changes: 3 additions & 3 deletions src/stream/tests/integration_tests/eowc_over_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ async fn test_over_window() {
// lag(x, 1)
WindowFuncCall {
kind: WindowFuncKind::Aggregate(AggKind::FirstValue),
args: AggArgs::Unary(DataType::Int32, 3),
args: AggArgs::from_iter([(DataType::Int32, 3)]),
return_type: DataType::Int32,
frame: Frame::rows(FrameBound::Preceding(1), FrameBound::Preceding(1)),
},
// lead(x, 1)
WindowFuncCall {
kind: WindowFuncKind::Aggregate(AggKind::FirstValue),
args: AggArgs::Unary(DataType::Int32, 3),
args: AggArgs::from_iter([(DataType::Int32, 3)]),
return_type: DataType::Int32,
frame: Frame::rows(FrameBound::Following(1), FrameBound::Following(1)),
},
Expand Down Expand Up @@ -186,7 +186,7 @@ async fn test_over_window_aggregate() {
let store = MemoryStateStore::new();
let calls = vec![WindowFuncCall {
kind: WindowFuncKind::Aggregate(AggKind::Sum),
args: AggArgs::Unary(DataType::Int32, 3),
args: AggArgs::from_iter([(DataType::Int32, 3)]),
return_type: DataType::Int64,
frame: Frame::rows(FrameBound::Preceding(1), FrameBound::Following(1)),
}];
Expand Down
10 changes: 5 additions & 5 deletions src/stream/tests/integration_tests/over_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ async fn test_over_window_lag_lead_append_only() {
// lag(x, 1)
WindowFuncCall {
kind: WindowFuncKind::Aggregate(AggKind::FirstValue),
args: AggArgs::Unary(DataType::Int32, 3),
args: AggArgs::from_iter([(DataType::Int32, 3)]),
return_type: DataType::Int32,
frame: Frame::rows(FrameBound::Preceding(1), FrameBound::Preceding(1)),
},
// lead(x, 1)
WindowFuncCall {
kind: WindowFuncKind::Aggregate(AggKind::FirstValue),
args: AggArgs::Unary(DataType::Int32, 3),
args: AggArgs::from_iter([(DataType::Int32, 3)]),
return_type: DataType::Int32,
frame: Frame::rows(FrameBound::Following(1), FrameBound::Following(1)),
},
Expand Down Expand Up @@ -216,14 +216,14 @@ async fn test_over_window_lag_lead_with_updates() {
// lag(x, 1)
WindowFuncCall {
kind: WindowFuncKind::Aggregate(AggKind::FirstValue),
args: AggArgs::Unary(DataType::Int32, 3),
args: AggArgs::from_iter([(DataType::Int32, 3)]),
return_type: DataType::Int32,
frame: Frame::rows(FrameBound::Preceding(1), FrameBound::Preceding(1)),
},
// lead(x, 1)
WindowFuncCall {
kind: WindowFuncKind::Aggregate(AggKind::FirstValue),
args: AggArgs::Unary(DataType::Int32, 3),
args: AggArgs::from_iter([(DataType::Int32, 3)]),
return_type: DataType::Int32,
frame: Frame::rows(FrameBound::Following(1), FrameBound::Following(1)),
},
Expand Down Expand Up @@ -391,7 +391,7 @@ async fn test_over_window_sum() {
// )
WindowFuncCall {
kind: WindowFuncKind::Aggregate(AggKind::Sum),
args: AggArgs::Unary(DataType::Int32, 3),
args: AggArgs::from_iter([(DataType::Int32, 3)]),
return_type: DataType::Int64,
frame: Frame::rows_with_exclusion(
FrameBound::Preceding(1),
Expand Down

0 comments on commit 873ee7b

Please sign in to comment.