Skip to content

Commit

Permalink
build: modify code to comply with latest clippy requirement (apache#9725
Browse files Browse the repository at this point in the history
)

* fix CI clippy

* fix scalar size test

* fix tests

* fix tests
  • Loading branch information
comphead authored and wiedld committed Apr 1, 2024
1 parent fc0da8a commit 581e747
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion datafusion/common/src/scalar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4453,7 +4453,8 @@ mod tests {
// The alignment requirements differ across architectures and
// thus the size of the enum appears to as well

assert_eq!(std::mem::size_of::<ScalarValue>(), 48);
// The value can be changed depending on rust version
assert_eq!(std::mem::size_of::<ScalarValue>(), 64);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/tests/fuzz_cases/aggregate_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use tokio::task::JoinSet;
/// same results
#[tokio::test(flavor = "multi_thread")]
async fn streaming_aggregate_test() {
let test_cases = vec![
let test_cases = [
vec!["a"],
vec!["b", "a"],
vec!["c", "a"],
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 @@ -397,7 +397,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
4 changes: 2 additions & 2 deletions datafusion/functions/benches/regx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn data(rng: &mut ThreadRng) -> StringArray {
}

fn regex(rng: &mut ThreadRng) -> StringArray {
let samples = vec![
let samples = [
".*([A-Z]{1}).*".to_string(),
"^(A).*".to_string(),
r#"[\p{Letter}-]+"#.to_string(),
Expand All @@ -60,7 +60,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
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,12 @@ struct ConstEvaluator<'a> {
input_batch: RecordBatch,
}

#[allow(dead_code)]
/// The simplify result of ConstEvaluator
enum ConstSimplifyResult {
// Expr was simplifed and contains the new expression
Simplified(ScalarValue),
// Evalaution encountered an error, contains the original expression
// Evaluation encountered an error, contains the original expression
SimplifyRuntimeError(DataFusionError, Expr),
}

Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/benches/to_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn data(rng: &mut ThreadRng) -> Date32Array {
}

fn patterns(rng: &mut ThreadRng) -> StringArray {
let samples = vec![
let samples = [
"%Y:%m:%d".to_string(),
"%d-%m-%Y".to_string(),
"%d%m%Y".to_string(),
Expand Down
6 changes: 3 additions & 3 deletions datafusion/physical-expr/src/equivalence/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,19 +535,19 @@ mod tests {

#[test]
fn test_remove_redundant_entries_eq_group() -> Result<()> {
let entries = vec![
let entries = [
EquivalenceClass::new(vec![lit(1), lit(1), lit(2)]),
// This group is meaningless should be removed
EquivalenceClass::new(vec![lit(3), lit(3)]),
EquivalenceClass::new(vec![lit(4), lit(5), lit(6)]),
];
// Given equivalences classes are not in succinct form.
// Expected form is the most plain representation that is functionally same.
let expected = vec![
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);
let mut eq_groups = EquivalenceGroup::new(entries.to_vec());
eq_groups.remove_redundant_entries();

let eq_groups = eq_groups.classes;
Expand Down
4 changes: 2 additions & 2 deletions datafusion/physical-expr/src/equivalence/ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ 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![
let col_exprs = [
col("a", &test_schema)?,
col("b", &test_schema)?,
col("c", &test_schema)?,
Expand Down Expand Up @@ -815,7 +815,7 @@ mod tests {
Operator::Plus,
col("b", &test_schema)?,
)) as Arc<dyn PhysicalExpr>;
let exprs = vec![
let exprs = [
col("a", &test_schema)?,
col("b", &test_schema)?,
col("c", &test_schema)?,
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/equivalence/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,7 @@ mod tests {
Operator::Plus,
col("b", &test_schema)?,
)) as Arc<dyn PhysicalExpr>;
let exprs = vec![
let exprs = [
col("a", &test_schema)?,
col("b", &test_schema)?,
col("c", &test_schema)?,
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-plan/src/sorts/partial_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ mod tests {
#[tokio::test]
async fn test_partial_sort2() -> Result<()> {
let task_ctx = Arc::new(TaskContext::default());
let source_tables = vec![
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]),
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-plan/src/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ mod tests {
let col_e = &col("e", &schema)?;
let col_f = &col("f", &schema)?;
let options = SortOptions::default();
let test_cases = vec![
let test_cases = [
//-----------TEST CASE 1----------//
(
// First child orderings
Expand Down
1 change: 1 addition & 0 deletions datafusion/substrait/src/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use substrait::proto::Plan;
use std::fs::OpenOptions;
use std::io::{Read, Write};

#[allow(clippy::suspicious_open_options)]
pub async fn serialize(sql: &str, ctx: &SessionContext, path: &str) -> Result<()> {
let protobuf_out = serialize_bytes(sql, ctx).await;
let mut file = OpenOptions::new().create(true).write(true).open(path)?;
Expand Down

0 comments on commit 581e747

Please sign in to comment.