Skip to content

Commit

Permalink
Fix chrono-rs clippy (#2949)
Browse files Browse the repository at this point in the history
* fix chrono-rs-clippy

* enable chrono-tz in clippy
  • Loading branch information
waitingkuo authored Oct 27, 2022
1 parent 4cef58e commit d625f0a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/arrow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,4 @@ jobs:
run: cargo clippy -p arrow-select --all-targets --all-features
- name: Clippy arrow
run: |
cargo clippy -p arrow --features=prettyprint,csv,ipc,test_utils,ffi,ipc_compression,dyn_cmp_dict,dyn_arith_dict --all-targets -- -D warnings
cargo clippy -p arrow --features=prettyprint,csv,ipc,test_utils,ffi,ipc_compression,dyn_cmp_dict,dyn_arith_dict,chrono-tz --all-targets -- -D warnings
3 changes: 1 addition & 2 deletions arrow/src/compute/kernels/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5499,8 +5499,7 @@ mod tests {
.with_timezone(tz_name.clone()),
),
Arc::new(
TimestampNanosecondArray::from(vec![1000, 2000])
.with_timezone(tz_name.clone()),
TimestampNanosecondArray::from(vec![1000, 2000]).with_timezone(tz_name),
),
Arc::new(Date32Array::from(vec![1000, 2000])),
Arc::new(Date64Array::from(vec![1000, 2000])),
Expand Down
6 changes: 2 additions & 4 deletions arrow/src/compute/kernels/temporal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,10 +1178,8 @@ mod tests {
// The offset (difference to UTC) is +11:00. Note that daylight savings is in effect on 2021-10-30.
// When daylight savings is not in effect, Australia/Sydney has an offset difference of +10:00.

let a = TimestampMillisecondArray::from_opt_vec(
vec![Some(1635577147000)],
Some("Australia/Sydney".to_string()),
);
let a = TimestampMillisecondArray::from(vec![Some(1635577147000)])
.with_timezone("Australia/Sydney".to_string());
let b = hour(&a).unwrap();
assert_eq!(17, b.value(0));
}
Expand Down
18 changes: 9 additions & 9 deletions arrow/src/csv/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,19 +610,19 @@ sed do eiusmod tempor,-556132.25,1,,2019-04-18T02:45:55.555000000,23:46:03,foo
Field::new("c2", DataType::Timestamp(TimeUnit::Millisecond, None), true),
]);

let c1 = TimestampMillisecondArray::from_opt_vec(
let c1 = TimestampMillisecondArray::from(
// 1555584887 converts to 2019-04-18, 20:54:47 in time zone Australia/Sydney (AEST).
// The offset (difference to UTC) is +10:00.
// 1635577147 converts to 2021-10-30 17:59:07 in time zone Australia/Sydney (AEDT)
// The offset (difference to UTC) is +11:00. Note that daylight savings is in effect on 2021-10-30.
//
vec![Some(1555584887378), Some(1635577147000)],
Some("Australia/Sydney".to_string()),
);
let c2 = TimestampMillisecondArray::from_opt_vec(
vec![Some(1555584887378), Some(1635577147000)],
None,
);
)
.with_timezone("Australia/Sydney".to_string());
let c2 = TimestampMillisecondArray::from(vec![
Some(1555584887378),
Some(1635577147000),
]);
let batch =
RecordBatch::try_new(Arc::new(schema), vec![Arc::new(c1), Arc::new(c2)])
.unwrap();
Expand Down Expand Up @@ -711,7 +711,7 @@ sed do eiusmod tempor,-556132.25,1,,2019-04-18T02:45:55.555000000,23:46:03,foo
];
let c1 = Date32Array::from(vec![3, 2, 1]);
let c2 = Date64Array::from(vec![3, 2, 1]);
let c3 = TimestampNanosecondArray::from_vec(nanoseconds.clone(), None);
let c3 = TimestampNanosecondArray::from(nanoseconds.clone());

let batch = RecordBatch::try_new(
Arc::new(schema.clone()),
Expand Down Expand Up @@ -756,7 +756,7 @@ sed do eiusmod tempor,-556132.25,1,,2019-04-18T02:45:55.555000000,23:46:03,foo
let expected = vec![Some(3), Some(2), Some(1)];
assert_eq!(actual, expected);
let actual = c3.into_iter().collect::<Vec<_>>();
let expected = nanoseconds.into_iter().map(|x| Some(x)).collect::<Vec<_>>();
let expected = nanoseconds.into_iter().map(Some).collect::<Vec<_>>();
assert_eq!(actual, expected);
}
}

0 comments on commit d625f0a

Please sign in to comment.