Skip to content

Commit

Permalink
minor: fix cargo clippy some warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwener committed Mar 4, 2024
1 parent 1a4dc00 commit 2451e98
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 48 deletions.
6 changes: 2 additions & 4 deletions datafusion/core/tests/fuzz_cases/aggregate_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,14 @@ use test_utils::{add_empty_batches, StringBatchGenerator};
/// same results
#[tokio::test(flavor = "multi_thread")]
async fn streaming_aggregate_test() {
let test_cases = vec![
vec!["a"],
let test_cases = [vec!["a"],
vec!["b", "a"],
vec!["c", "a"],
vec!["c", "b", "a"],
vec!["d", "a"],
vec!["d", "b", "a"],
vec!["d", "c", "a"],
vec!["d", "c", "b", "a"],
];
vec!["d", "c", "b", "a"]];
let n = 300;
let distincts = vec![10, 20];
for distinct in distincts {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/src/expr_rewriter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ mod test {
let expr = col("a") + col("b");
let schema_a =
make_schema_with_empty_metadata(vec![make_field("\"tableA\"", "a")]);
let schemas = vec![schema_a];
let schemas = [schema_a];
let schemas = schemas.iter().collect::<Vec<_>>();

let error =
Expand Down
8 changes: 3 additions & 5 deletions datafusion/physical-expr/benches/regexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ fn data(rng: &mut ThreadRng) -> StringArray {
}

fn regex(rng: &mut ThreadRng) -> StringArray {
let samples = vec![
".*([A-Z]{1}).*".to_string(),
let samples = [".*([A-Z]{1}).*".to_string(),
"^(A).*".to_string(),
r#"[\p{Letter}-]+"#.to_string(),
r#"[\p{L}-]+"#.to_string(),
"[a-zA-Z]_[a-zA-Z]{2}".to_string(),
];
"[a-zA-Z]_[a-zA-Z]{2}".to_string()];
let mut data: Vec<String> = vec![];
for _ in 0..1000 {
data.push(samples.choose(rng).unwrap().to_string());
Expand All @@ -63,7 +61,7 @@ fn regex(rng: &mut ThreadRng) -> StringArray {
}

fn flags(rng: &mut ThreadRng) -> StringArray {
let samples = vec![Some("i".to_string()), Some("im".to_string()), None];
let samples = [Some("i".to_string()), Some("im".to_string()), None];
let mut sb = StringBuilder::new();
for _ in 0..1000 {
let sample = samples.choose(rng).unwrap();
Expand Down
6 changes: 2 additions & 4 deletions datafusion/physical-expr/benches/to_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,11 @@ fn data(rng: &mut ThreadRng) -> Date32Array {
}

fn patterns(rng: &mut ThreadRng) -> StringArray {
let samples = vec![
"%Y:%m:%d".to_string(),
let samples = ["%Y:%m:%d".to_string(),
"%d-%m-%Y".to_string(),
"%d%m%Y".to_string(),
"%Y%m%d".to_string(),
"%Y...%m...%d".to_string(),
];
"%Y...%m...%d".to_string()];
let mut data: Vec<String> = vec![];
for _ in 0..1000 {
data.push(samples.choose(rng).unwrap().to_string());
Expand Down
6 changes: 2 additions & 4 deletions datafusion/physical-expr/src/equivalence/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,8 @@ mod tests {
];
// Given equivalences classes are not in succinct form.
// Expected form is the most plain representation that is functionally same.
let expected = vec![
EquivalenceClass::new(vec![lit(1), lit(2)]),
EquivalenceClass::new(vec![lit(4), lit(5), lit(6)]),
];
let expected = [EquivalenceClass::new(vec![lit(1), lit(2)]),
EquivalenceClass::new(vec![lit(4), lit(5), lit(6)])];
let mut eq_groups = EquivalenceGroup::new(entries);
eq_groups.remove_redundant_entries();

Expand Down
18 changes: 7 additions & 11 deletions datafusion/physical-expr/src/equivalence/ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ mod tests {
vec![
(col_a, options),
(col_c, options),
(&floor_a, options),
(floor_a, options),
(&a_plus_b, options),
],
// expected: requirement is not satisfied.
Expand All @@ -505,8 +505,8 @@ mod tests {
vec![
(col_a, options),
(col_b, options),
(&col_c, options),
(&floor_a, options),
(col_c, options),
(floor_a, options),
],
// expected: requirement is satisfied.
true,
Expand Down Expand Up @@ -746,14 +746,12 @@ mod tests {
// Generate a data that satisfies properties given
let table_data_with_properties =
generate_table_for_eq_properties(&eq_properties, N_ELEMENTS, N_DISTINCT)?;
let col_exprs = vec![
col("a", &test_schema)?,
let col_exprs = [col("a", &test_schema)?,
col("b", &test_schema)?,
col("c", &test_schema)?,
col("d", &test_schema)?,
col("e", &test_schema)?,
col("f", &test_schema)?,
];
col("f", &test_schema)?];

for n_req in 0..=col_exprs.len() {
for exprs in col_exprs.iter().combinations(n_req) {
Expand Down Expand Up @@ -815,16 +813,14 @@ mod tests {
Operator::Plus,
col("b", &test_schema)?,
)) as Arc<dyn PhysicalExpr>;
let exprs = vec![
col("a", &test_schema)?,
let exprs = [col("a", &test_schema)?,
col("b", &test_schema)?,
col("c", &test_schema)?,
col("d", &test_schema)?,
col("e", &test_schema)?,
col("f", &test_schema)?,
floor_a,
a_plus_b,
];
a_plus_b];

for n_req in 0..=exprs.len() {
for exprs in exprs.iter().combinations(n_req) {
Expand Down
6 changes: 3 additions & 3 deletions datafusion/physical-expr/src/equivalence/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ mod tests {
// orderings
vec![
// [a + b ASC, c ASC]
vec![(&a_plus_b, option_asc), (&col_c, option_asc)],
vec![(&a_plus_b, option_asc), (col_c, option_asc)],
],
// projection exprs
vec![
Expand Down Expand Up @@ -546,7 +546,7 @@ mod tests {
vec![
(col_a, option_asc),
(col_c, option_asc),
(&col_b, option_asc),
(col_b, option_asc),
],
],
// proj exprs
Expand Down Expand Up @@ -805,7 +805,7 @@ mod tests {
// [a+b ASC, round(c) ASC, c_new ASC]
vec![
(&a_new_plus_b_new, option_asc),
(&col_round_c_res, option_asc),
(col_round_c_res, option_asc),
],
// [a+b ASC, c_new ASC]
vec![(&a_new_plus_b_new, option_asc), (col_c_new, option_asc)],
Expand Down
6 changes: 2 additions & 4 deletions datafusion/physical-expr/src/equivalence/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1791,16 +1791,14 @@ mod tests {
Operator::Plus,
col("b", &test_schema)?,
)) as Arc<dyn PhysicalExpr>;
let exprs = vec![
col("a", &test_schema)?,
let exprs = [col("a", &test_schema)?,
col("b", &test_schema)?,
col("c", &test_schema)?,
col("d", &test_schema)?,
col("e", &test_schema)?,
col("f", &test_schema)?,
floor_a,
a_plus_b,
];
a_plus_b];

for n_req in 0..=exprs.len() {
for exprs in exprs.iter().combinations(n_req) {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/execution_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl ExecutionProps {
) -> Option<Arc<dyn VarProvider + Send + Sync>> {
self.var_providers
.as_ref()
.and_then(|var_providers| var_providers.get(&var_type).map(Arc::clone))
.and_then(|var_providers| var_providers.get(&var_type).cloned())
}
}

Expand Down
6 changes: 2 additions & 4 deletions datafusion/physical-plan/src/sorts/partial_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,7 @@ mod tests {
#[tokio::test]
async fn test_partial_sort2() -> Result<()> {
let task_ctx = Arc::new(TaskContext::default());
let source_tables = vec![
test::build_table_scan_i32(
let source_tables = [test::build_table_scan_i32(
("a", &vec![0, 0, 0, 0, 1, 1, 1, 1]),
("b", &vec![1, 1, 3, 3, 4, 4, 2, 2]),
("c", &vec![7, 6, 5, 4, 3, 2, 1, 0]),
Expand All @@ -588,8 +587,7 @@ mod tests {
("a", &vec![0, 0, 0, 0, 1, 1, 1, 1]),
("b", &vec![1, 1, 3, 3, 2, 2, 4, 4]),
("c", &vec![7, 6, 5, 4, 1, 0, 3, 2]),
),
];
)];
let schema = Schema::new(vec![
Field::new("a", DataType::Int32, false),
Field::new("b", DataType::Int32, false),
Expand Down
7 changes: 2 additions & 5 deletions datafusion/physical-plan/src/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,7 @@ mod tests {
let col_e = &col("e", &schema)?;
let col_f = &col("f", &schema)?;
let options = SortOptions::default();
let test_cases = vec![
//-----------TEST CASE 1----------//
(
let test_cases = [(
// First child orderings
vec![
// [a ASC, b ASC, f ASC]
Expand Down Expand Up @@ -782,8 +780,7 @@ mod tests {
// [a ASC, b ASC]
vec![(col_a, options), (col_b, options)],
],
),
];
)];

for (
test_idx,
Expand Down
4 changes: 2 additions & 2 deletions datafusion/sql/tests/sql_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2881,11 +2881,11 @@ impl ContextProvider for MockContextProvider {
}

fn get_function_meta(&self, name: &str) -> Option<Arc<ScalarUDF>> {
self.udfs.get(name).map(Arc::clone)
self.udfs.get(name).cloned()
}

fn get_aggregate_meta(&self, name: &str) -> Option<Arc<AggregateUDF>> {
self.udafs.get(name).map(Arc::clone)
self.udafs.get(name).cloned()
}

fn get_variable_type(&self, _: &[String]) -> Option<DataType> {
Expand Down

0 comments on commit 2451e98

Please sign in to comment.