Skip to content

Commit 69997fe

Browse files
authored
chore: Make rust clippy happy (#701)
* 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]>
1 parent 1d33828 commit 69997fe

File tree

8 files changed

+32
-32
lines changed

8 files changed

+32
-32
lines changed

native/core/benches/cast_from_string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ fn create_utf8_batch() -> RecordBatch {
7575
}
7676
}
7777
let array = b.finish();
78-
let batch = RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap();
79-
batch
78+
79+
RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap()
8080
}
8181

8282
fn config() -> Criterion {

native/core/benches/cast_numeric.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ fn create_int32_batch() -> RecordBatch {
6363
}
6464
}
6565
let array = b.finish();
66-
let batch = RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap();
67-
batch
66+
67+
RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap()
6868
}
6969

7070
fn config() -> Criterion {

native/core/benches/shuffle_writer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ fn create_batch() -> RecordBatch {
6565
}
6666
}
6767
let array = b.finish();
68-
let batch = RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap();
69-
batch
68+
69+
RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap()
7070
}
7171

7272
fn config() -> Criterion {

native/core/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ mod tests {
778778
_class: JClass,
779779
input: JString,
780780
) -> jstring {
781-
try_unwrap_or_throw(&e, |mut env| {
781+
try_unwrap_or_throw(e, |mut env| {
782782
let input: String = env
783783
.get_string(&input)
784784
.expect("Couldn't get java string!")

native/core/src/execution/datafusion/spark_hash.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ mod tests {
686686

687687
#[test]
688688
fn test_str() {
689-
let input = vec![
689+
let input = [
690690
"hello", "bar", "", "😁", "天地", "a", "ab", "abc", "abcd", "abcde",
691691
]
692692
.iter()

native/core/src/parquet/read/values.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ mod test {
11841184
let expected = hex::decode("8adb1834301dab37f1").unwrap();
11851185
let num = source.len() / 4;
11861186
let mut dest: Vec<u8> = vec![b' '; num];
1187-
copy_i32_to_i8(&source.as_bytes(), dest.as_mut_slice(), num);
1187+
copy_i32_to_i8(source.as_bytes(), dest.as_mut_slice(), num);
11881188
assert_eq!(expected.as_bytes(), dest.as_bytes());
11891189
}
11901190

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

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

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

@@ -1237,7 +1237,7 @@ mod test {
12371237
let expected = hex::decode("ffffff7f00000000000000800000000001000080000000000200008000000000030000800000000004000080000000000500008000000000060000800000000007000080000000000800008000000000").unwrap();
12381238
let num = source.len() / 4;
12391239
let mut dest: Vec<u8> = vec![b' '; num * 8];
1240-
copy_i32_to_u32(&source.as_bytes(), dest.as_mut_slice(), num);
1240+
copy_i32_to_u32(source.as_bytes(), dest.as_mut_slice(), num);
12411241
assert_eq!(expected.as_bytes(), dest.as_bytes());
12421242
}
12431243
}

native/spark-expr/src/cast.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,7 @@ mod tests {
18541854
"2020-01-01T",
18551855
] {
18561856
for eval_mode in &[EvalMode::Legacy, EvalMode::Ansi, EvalMode::Try] {
1857-
assert_eq!(date_parser(*date, *eval_mode).unwrap(), Some(18262));
1857+
assert_eq!(date_parser(date, *eval_mode).unwrap(), Some(18262));
18581858
}
18591859
}
18601860

@@ -1875,14 +1875,14 @@ mod tests {
18751875
"--262143-12-31 ",
18761876
] {
18771877
for eval_mode in &[EvalMode::Legacy, EvalMode::Try] {
1878-
assert_eq!(date_parser(*date, *eval_mode).unwrap(), None);
1878+
assert_eq!(date_parser(date, *eval_mode).unwrap(), None);
18791879
}
1880-
assert!(date_parser(*date, EvalMode::Ansi).is_err());
1880+
assert!(date_parser(date, EvalMode::Ansi).is_err());
18811881
}
18821882

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

@@ -1898,7 +1898,7 @@ mod tests {
18981898
"-0973250",
18991899
] {
19001900
for eval_mode in &[EvalMode::Legacy, EvalMode::Try, EvalMode::Ansi] {
1901-
assert_eq!(date_parser(*date, *eval_mode).unwrap(), None);
1901+
assert_eq!(date_parser(date, *eval_mode).unwrap(), None);
19021902
}
19031903
}
19041904
}

native/spark-expr/src/kernels/temporal.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ mod tests {
838838
assert!(array.values().get(i) >= a.values().get(i))
839839
}
840840
}
841-
_ => assert!(false),
841+
_ => unreachable!(),
842842
}
843843
}
844844
}
@@ -854,9 +854,9 @@ mod tests {
854854
let mut vec: Vec<i32> = Vec::with_capacity(size * formats.len());
855855
let mut fmt_vec: Vec<&str> = Vec::with_capacity(size * formats.len());
856856
for i in 0..size {
857-
for j in 0..formats.len() {
857+
for fmt_value in &formats {
858858
vec.push(i as i32 * 1_000_001);
859-
fmt_vec.push(formats[j]);
859+
fmt_vec.push(fmt_value);
860860
}
861861
}
862862

@@ -928,7 +928,7 @@ mod tests {
928928
)
929929
}
930930
} else {
931-
assert!(false)
931+
unreachable!()
932932
}
933933
if let Ok(a) = date_trunc_array_fmt_dyn(&array_dict, &fmt_array) {
934934
for i in 0..array.len() {
@@ -937,7 +937,7 @@ mod tests {
937937
)
938938
}
939939
} else {
940-
assert!(false)
940+
unreachable!()
941941
}
942942
if let Ok(a) = date_trunc_array_fmt_dyn(&array, &fmt_dict) {
943943
for i in 0..array.len() {
@@ -946,7 +946,7 @@ mod tests {
946946
)
947947
}
948948
} else {
949-
assert!(false)
949+
unreachable!()
950950
}
951951
if let Ok(a) = date_trunc_array_fmt_dyn(&array_dict, &fmt_dict) {
952952
for i in 0..array.len() {
@@ -955,7 +955,7 @@ mod tests {
955955
)
956956
}
957957
} else {
958-
assert!(false)
958+
unreachable!()
959959
}
960960
}
961961

@@ -991,7 +991,7 @@ mod tests {
991991
assert!(array.values().get(i) >= a.values().get(i))
992992
}
993993
}
994-
_ => assert!(false),
994+
_ => unreachable!(),
995995
}
996996
}
997997
}
@@ -1023,9 +1023,9 @@ mod tests {
10231023
let mut vec: Vec<i64> = Vec::with_capacity(size * formats.len());
10241024
let mut fmt_vec: Vec<&str> = Vec::with_capacity(size * formats.len());
10251025
for i in 0..size {
1026-
for j in 0..formats.len() {
1026+
for fmt_value in &formats {
10271027
vec.push(i as i64 * 1_000_000_001);
1028-
fmt_vec.push(formats[j]);
1028+
fmt_vec.push(fmt_value);
10291029
}
10301030
}
10311031

@@ -1103,7 +1103,7 @@ mod tests {
11031103
)
11041104
}
11051105
} else {
1106-
assert!(false)
1106+
unreachable!()
11071107
}
11081108
if let Ok(a) = timestamp_trunc_array_fmt_dyn(&array_dict, &fmt_array) {
11091109
for i in 0..array.len() {
@@ -1116,7 +1116,7 @@ mod tests {
11161116
)
11171117
}
11181118
} else {
1119-
assert!(false)
1119+
unreachable!()
11201120
}
11211121
if let Ok(a) = timestamp_trunc_array_fmt_dyn(&array, &fmt_dict) {
11221122
for i in 0..array.len() {
@@ -1129,7 +1129,7 @@ mod tests {
11291129
)
11301130
}
11311131
} else {
1132-
assert!(false)
1132+
unreachable!()
11331133
}
11341134
if let Ok(a) = timestamp_trunc_array_fmt_dyn(&array_dict, &fmt_dict) {
11351135
for i in 0..array.len() {
@@ -1142,7 +1142,7 @@ mod tests {
11421142
)
11431143
}
11441144
} else {
1145-
assert!(false)
1145+
unreachable!()
11461146
}
11471147
}
11481148
}

0 commit comments

Comments
 (0)