Skip to content

Commit 992fe5a

Browse files
committed
fix the clippy
1 parent b72701c commit 992fe5a

File tree

4 files changed

+44
-33
lines changed

4 files changed

+44
-33
lines changed

datafusion/src/execution/context.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -3914,10 +3914,13 @@ mod tests {
39143914
.await?;
39153915

39163916
// decimal query
3917-
let result = plan_and_collect(&mut ctx, "select min(c1) from aggregate_simple")
3918-
.await
3919-
.unwrap();
3920-
println!("{:?}", result);
3917+
3918+
// let result = plan_and_collect(&mut ctx, "select min(c1) from aggregate_simple")
3919+
// .await
3920+
// .unwrap();
3921+
//
3922+
// println!("{:?}", result);
3923+
39213924
Ok(())
39223925
}
39233926

datafusion/src/physical_plan/expressions/average.rs

+17-10
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,23 @@ pub fn avg_return_type(arg_type: &DataType) -> Result<DataType> {
6363
}
6464

6565
pub(crate) fn is_avg_support_arg_type(arg_type: &DataType) -> bool {
66-
match arg_type {
67-
// TODO: do we need to support the unsigned data type?
68-
DataType::UInt8 | DataType::UInt16 | DataType::UInt32 | DataType::UInt64 => true,
69-
DataType::Int8 | DataType::Int16 | DataType::Int32 | DataType::Int64 => true,
70-
DataType::Float16 | DataType::Float32 | DataType::Float64 => true,
71-
// TODO support the decimal data type
72-
DataType::Decimal(_, _) => true,
73-
// TODO support the interva
74-
_ => false,
75-
}
66+
// TODO support the interval
67+
// TODO: do we need to support the unsigned data type?
68+
matches!(
69+
arg_type,
70+
DataType::UInt8
71+
| DataType::UInt16
72+
| DataType::UInt32
73+
| DataType::UInt64
74+
| DataType::Int8
75+
| DataType::Int16
76+
| DataType::Int32
77+
| DataType::Int64
78+
| DataType::Float16
79+
| DataType::Float32
80+
| DataType::Float64
81+
| DataType::Decimal(_, _)
82+
)
7683
}
7784

7885
impl Avg {

datafusion/src/physical_plan/expressions/sum.rs

+17-10
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,23 @@ pub fn sum_return_type(arg_type: &DataType) -> Result<DataType> {
6464
}
6565

6666
pub(crate) fn is_sum_support_arg_type(arg_type: &DataType) -> bool {
67-
match arg_type {
68-
// TODO: do we need to support the unsigned data type?
69-
DataType::UInt8 | DataType::UInt16 | DataType::UInt32 | DataType::UInt64 => true,
70-
DataType::Int8 | DataType::Int16 | DataType::Int32 | DataType::Int64 => true,
71-
DataType::Float16 | DataType::Float32 | DataType::Float64 => true,
72-
// TODO support the decimal data type
73-
DataType::Decimal(_, _) => true,
74-
// TODO support the interva
75-
_ => false,
76-
}
67+
// TODO support the interval
68+
// TODO: do we need to support the unsigned data type?
69+
matches!(
70+
arg_type,
71+
DataType::UInt8
72+
| DataType::UInt16
73+
| DataType::UInt32
74+
| DataType::UInt64
75+
| DataType::Int8
76+
| DataType::Int16
77+
| DataType::Int32
78+
| DataType::Int64
79+
| DataType::Float16
80+
| DataType::Float32
81+
| DataType::Float64
82+
| DataType::Decimal(_, _)
83+
)
7784
}
7885

7986
impl Sum {

datafusion/src/physical_plan/type_coercion.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ fn maybe_data_types(
145145
valid_types: &[DataType],
146146
current_types: &[DataType],
147147
) -> Option<Vec<DataType>> {
148-
// TODO liukun4515
149-
150148
if valid_types.len() != current_types.len() {
151149
return None;
152150
}
@@ -157,13 +155,10 @@ fn maybe_data_types(
157155

158156
if current_type == valid_type {
159157
new_type.push(current_type.clone())
158+
} else if can_coerce_from(valid_type, current_type) {
159+
new_type.push(valid_type.clone())
160160
} else {
161-
if can_coerce_from(valid_type, current_type) {
162-
new_type.push(valid_type.clone())
163-
} else {
164-
// not possible
165-
return None;
166-
}
161+
return None;
167162
}
168163
}
169164
Some(new_type)
@@ -175,7 +170,6 @@ fn maybe_data_types(
175170
/// See the module level documentation for more detail on coercion.
176171
fn can_coerce_from(type_into: &DataType, type_from: &DataType) -> bool {
177172
use self::DataType::*;
178-
// TODO liukun4515
179173
match type_into {
180174
// TODO, decimal data type, we just support the decimal
181175
Int8 => matches!(type_from, Int8),

0 commit comments

Comments
 (0)