Skip to content

Commit dc280bf

Browse files
committed
revmoe redundant clone
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
1 parent 067d4ad commit dc280bf

5 files changed

Lines changed: 12 additions & 13 deletions

File tree

datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,11 @@ impl<'a> ConstEvaluator<'a> {
395395
"Could not evaluate the expression, found a result of length {}",
396396
a.len()
397397
)
398+
} else if as_list_array(&a).is_ok() || as_large_list_array(&a).is_ok() {
399+
Ok(ScalarValue::ListArr(a))
398400
} else {
399-
if as_list_array(&a).is_ok() || as_large_list_array(&a).is_ok() {
400-
Ok(ScalarValue::ListArr(a))
401-
} else {
402-
// Non-ListArray
403-
ScalarValue::try_from_array(&a, 0)
404-
}
401+
// Non-ListArray
402+
ScalarValue::try_from_array(&a, 0)
405403
}
406404
}
407405
ColumnarValue::Scalar(s) => Ok(s),
@@ -3267,7 +3265,7 @@ mod tests {
32673265
let expr_x = col("c3").gt(lit(3_i64));
32683266
let expr_y = (col("c4") + lit(2_u32)).lt(lit(10_u32));
32693267
let expr_z = col("c1").in_list(vec![lit("a"), lit("b")], true);
3270-
let expr = expr_x.clone().and(expr_y.clone().or(expr_z));
3268+
let expr = expr_x.clone().and(expr_y.or(expr_z));
32713269

32723270
// All guaranteed null
32733271
let guarantees = vec![
@@ -3342,7 +3340,7 @@ mod tests {
33423340
col("c4"),
33433341
NullableInterval::from(ScalarValue::UInt32(Some(3))),
33443342
)];
3345-
let output = simplify_with_guarantee(expr.clone(), guarantees);
3343+
let output = simplify_with_guarantee(expr, guarantees);
33463344
assert_eq!(&output, &expr_x);
33473345
}
33483346
}

datafusion/optimizer/src/simplify_expressions/guarantees.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ mod tests {
216216

217217
// x IS NULL => guaranteed false
218218
let expr = col("x").is_null();
219-
let output = expr.clone().rewrite(&mut rewriter).unwrap();
219+
let output = expr.rewrite(&mut rewriter).unwrap();
220220
assert_eq!(output, lit(false));
221221

222222
// x IS NOT NULL => guaranteed true
223223
let expr = col("x").is_not_null();
224-
let output = expr.clone().rewrite(&mut rewriter).unwrap();
224+
let output = expr.rewrite(&mut rewriter).unwrap();
225225
assert_eq!(output, lit(true));
226226
}
227227

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ mod tests {
204204
};
205205
use arrow::datatypes::DataType;
206206
use datafusion_common::internal_err;
207+
use datafusion_common::DataFusionError;
207208

208209
macro_rules! state_to_vec {
209210
($LIST:expr, $DATA_TYPE:ident, $PRIM_TY:ty) => {{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ mod tests {
15011501
.with_data_type(dt.clone());
15021502
let expected: ArrayRef =
15031503
Arc::new(TimestampMicrosecondArray::from(vec![5]).with_data_type(dt.clone()));
1504-
generic_test_op_new!(Arc::new(actual), dt.clone(), Max, &expected)
1504+
generic_test_op_new!(Arc::new(actual), dt, Max, &expected)
15051505
}
15061506

15071507
#[test]
@@ -1511,7 +1511,7 @@ mod tests {
15111511
.with_data_type(dt.clone());
15121512
let expected: ArrayRef =
15131513
Arc::new(TimestampMicrosecondArray::from(vec![5]).with_data_type(dt.clone()));
1514-
generic_test_op_new!(Arc::new(actual), dt.clone(), Max, &expected)
1514+
generic_test_op_new!(Arc::new(actual), dt, Max, &expected)
15151515
}
15161516

15171517
#[test]

datafusion/physical-expr/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ mod tests {
18031803
options: SortOptions::default(),
18041804
}]),
18051805
EquivalenceProperties::new(Arc::new(schema.clone())),
1806-
OrderingEquivalenceProperties::new(Arc::new(schema.clone())),
1806+
OrderingEquivalenceProperties::new(Arc::new(schema)),
18071807
)?;
18081808

18091809
assert_eq!(

0 commit comments

Comments
 (0)