Skip to content

Commit

Permalink
chore: Make rust clippy happy (#701)
Browse files Browse the repository at this point in the history
* chore: Make rust clippy happy

Signed-off-by: Xuanwo <[email protected]>

* Format code

Signed-off-by: Xuanwo <[email protected]>

---------

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Jul 21, 2024
1 parent 1d33828 commit 69997fe
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions native/core/benches/cast_from_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ fn create_utf8_batch() -> RecordBatch {
}
}
let array = b.finish();
let batch = RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap();
batch

RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap()
}

fn config() -> Criterion {
Expand Down
4 changes: 2 additions & 2 deletions native/core/benches/cast_numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ fn create_int32_batch() -> RecordBatch {
}
}
let array = b.finish();
let batch = RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap();
batch

RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap()
}

fn config() -> Criterion {
Expand Down
4 changes: 2 additions & 2 deletions native/core/benches/shuffle_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ fn create_batch() -> RecordBatch {
}
}
let array = b.finish();
let batch = RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap();
batch

RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap()
}

fn config() -> Criterion {
Expand Down
2 changes: 1 addition & 1 deletion native/core/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ mod tests {
_class: JClass,
input: JString,
) -> jstring {
try_unwrap_or_throw(&e, |mut env| {
try_unwrap_or_throw(e, |mut env| {
let input: String = env
.get_string(&input)
.expect("Couldn't get java string!")
Expand Down
2 changes: 1 addition & 1 deletion native/core/src/execution/datafusion/spark_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ mod tests {

#[test]
fn test_str() {
let input = vec![
let input = [
"hello", "bar", "", "😁", "天地", "a", "ab", "abc", "abcd", "abcde",
]
.iter()
Expand Down
10 changes: 5 additions & 5 deletions native/core/src/parquet/read/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ mod test {
let expected = hex::decode("8adb1834301dab37f1").unwrap();
let num = source.len() / 4;
let mut dest: Vec<u8> = vec![b' '; num];
copy_i32_to_i8(&source.as_bytes(), dest.as_mut_slice(), num);
copy_i32_to_i8(source.as_bytes(), dest.as_mut_slice(), num);
assert_eq!(expected.as_bytes(), dest.as_bytes());
}

Expand All @@ -1196,7 +1196,7 @@ mod test {
let expected = hex::decode("8a00db001800340030001d00ab003700f100").unwrap();
let num = source.len() / 4;
let mut dest: Vec<u8> = vec![b' '; num * 2];
copy_i32_to_u8(&source.as_bytes(), dest.as_mut_slice(), num);
copy_i32_to_u8(source.as_bytes(), dest.as_mut_slice(), num);
assert_eq!(expected.as_bytes(), dest.as_bytes());
}

Expand All @@ -1208,7 +1208,7 @@ mod test {
let expected = hex::decode("8a0edb93182634f430021d2babe3378df147").unwrap();
let num = source.len() / 4;
let mut dest: Vec<u8> = vec![b' '; num * 2];
copy_i32_to_i16(&source.as_bytes(), dest.as_mut_slice(), num);
copy_i32_to_i16(source.as_bytes(), dest.as_mut_slice(), num);
assert_eq!(expected.as_bytes(), dest.as_bytes());
}

Expand All @@ -1224,7 +1224,7 @@ mod test {
.unwrap();
let num = source.len() / 4;
let mut dest: Vec<u8> = vec![b' '; num * 4];
copy_i32_to_u16(&source.as_bytes(), dest.as_mut_slice(), num);
copy_i32_to_u16(source.as_bytes(), dest.as_mut_slice(), num);
assert_eq!(expected.as_bytes(), dest.as_bytes());
}

Expand All @@ -1237,7 +1237,7 @@ mod test {
let expected = hex::decode("ffffff7f00000000000000800000000001000080000000000200008000000000030000800000000004000080000000000500008000000000060000800000000007000080000000000800008000000000").unwrap();
let num = source.len() / 4;
let mut dest: Vec<u8> = vec![b' '; num * 8];
copy_i32_to_u32(&source.as_bytes(), dest.as_mut_slice(), num);
copy_i32_to_u32(source.as_bytes(), dest.as_mut_slice(), num);
assert_eq!(expected.as_bytes(), dest.as_bytes());
}
}
10 changes: 5 additions & 5 deletions native/spark-expr/src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ mod tests {
"2020-01-01T",
] {
for eval_mode in &[EvalMode::Legacy, EvalMode::Ansi, EvalMode::Try] {
assert_eq!(date_parser(*date, *eval_mode).unwrap(), Some(18262));
assert_eq!(date_parser(date, *eval_mode).unwrap(), Some(18262));
}
}

Expand All @@ -1875,14 +1875,14 @@ mod tests {
"--262143-12-31 ",
] {
for eval_mode in &[EvalMode::Legacy, EvalMode::Try] {
assert_eq!(date_parser(*date, *eval_mode).unwrap(), None);
assert_eq!(date_parser(date, *eval_mode).unwrap(), None);
}
assert!(date_parser(*date, EvalMode::Ansi).is_err());
assert!(date_parser(date, EvalMode::Ansi).is_err());
}

for date in &["-3638-5"] {
for eval_mode in &[EvalMode::Legacy, EvalMode::Try, EvalMode::Ansi] {
assert_eq!(date_parser(*date, *eval_mode).unwrap(), Some(-2048160));
assert_eq!(date_parser(date, *eval_mode).unwrap(), Some(-2048160));
}
}

Expand All @@ -1898,7 +1898,7 @@ mod tests {
"-0973250",
] {
for eval_mode in &[EvalMode::Legacy, EvalMode::Try, EvalMode::Ansi] {
assert_eq!(date_parser(*date, *eval_mode).unwrap(), None);
assert_eq!(date_parser(date, *eval_mode).unwrap(), None);
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions native/spark-expr/src/kernels/temporal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ mod tests {
assert!(array.values().get(i) >= a.values().get(i))
}
}
_ => assert!(false),
_ => unreachable!(),
}
}
}
Expand All @@ -854,9 +854,9 @@ mod tests {
let mut vec: Vec<i32> = Vec::with_capacity(size * formats.len());
let mut fmt_vec: Vec<&str> = Vec::with_capacity(size * formats.len());
for i in 0..size {
for j in 0..formats.len() {
for fmt_value in &formats {
vec.push(i as i32 * 1_000_001);
fmt_vec.push(formats[j]);
fmt_vec.push(fmt_value);
}
}

Expand Down Expand Up @@ -928,7 +928,7 @@ mod tests {
)
}
} else {
assert!(false)
unreachable!()
}
if let Ok(a) = date_trunc_array_fmt_dyn(&array_dict, &fmt_array) {
for i in 0..array.len() {
Expand All @@ -937,7 +937,7 @@ mod tests {
)
}
} else {
assert!(false)
unreachable!()
}
if let Ok(a) = date_trunc_array_fmt_dyn(&array, &fmt_dict) {
for i in 0..array.len() {
Expand All @@ -946,7 +946,7 @@ mod tests {
)
}
} else {
assert!(false)
unreachable!()
}
if let Ok(a) = date_trunc_array_fmt_dyn(&array_dict, &fmt_dict) {
for i in 0..array.len() {
Expand All @@ -955,7 +955,7 @@ mod tests {
)
}
} else {
assert!(false)
unreachable!()
}
}

Expand Down Expand Up @@ -991,7 +991,7 @@ mod tests {
assert!(array.values().get(i) >= a.values().get(i))
}
}
_ => assert!(false),
_ => unreachable!(),
}
}
}
Expand Down Expand Up @@ -1023,9 +1023,9 @@ mod tests {
let mut vec: Vec<i64> = Vec::with_capacity(size * formats.len());
let mut fmt_vec: Vec<&str> = Vec::with_capacity(size * formats.len());
for i in 0..size {
for j in 0..formats.len() {
for fmt_value in &formats {
vec.push(i as i64 * 1_000_000_001);
fmt_vec.push(formats[j]);
fmt_vec.push(fmt_value);
}
}

Expand Down Expand Up @@ -1103,7 +1103,7 @@ mod tests {
)
}
} else {
assert!(false)
unreachable!()
}
if let Ok(a) = timestamp_trunc_array_fmt_dyn(&array_dict, &fmt_array) {
for i in 0..array.len() {
Expand All @@ -1116,7 +1116,7 @@ mod tests {
)
}
} else {
assert!(false)
unreachable!()
}
if let Ok(a) = timestamp_trunc_array_fmt_dyn(&array, &fmt_dict) {
for i in 0..array.len() {
Expand All @@ -1129,7 +1129,7 @@ mod tests {
)
}
} else {
assert!(false)
unreachable!()
}
if let Ok(a) = timestamp_trunc_array_fmt_dyn(&array_dict, &fmt_dict) {
for i in 0..array.len() {
Expand All @@ -1142,7 +1142,7 @@ mod tests {
)
}
} else {
assert!(false)
unreachable!()
}
}
}

0 comments on commit 69997fe

Please sign in to comment.