liamzwbao commented on code in PR #8233:
URL: https://github.com/apache/arrow-rs/pull/8233#discussion_r2308739717
##########
parquet-variant-compute/src/cast_to_variant.rs:
##########
@@ -2392,4 +2413,64 @@ mod tests {
}
}
}
+
+ fn run_test(values: ArrayRef, expected: Vec<Option<Variant>>) {
+ run_test_with_options(values, expected, true);
+ }
+
+ fn run_test_non_strict(values: ArrayRef, expected: Vec<Option<Variant>>) {
+ run_test_with_options(values, expected, false);
+ }
+
+ #[test]
+ fn test_cast_to_variant_non_strict_mode_date64() {
+ let date64_values = Date64Array::from(vec![Some(i64::MAX), Some(0),
Some(i64::MIN)]);
+
+ let values = Arc::new(date64_values);
+ run_test_non_strict(
+ values,
+ vec![
+ None,
+ Some(Variant::Date(Date64Type::to_naive_date_opt(0).unwrap())),
+ None,
+ ],
+ );
+ }
+
+ #[test]
+ fn test_cast_to_variant_non_strict_mode_time32() {
+ let time32_array = Time32SecondArray::from(vec![Some(90000),
Some(3600), Some(-1)]);
+
+ let values = Arc::new(time32_array);
+ run_test_non_strict(
+ values,
+ vec![
+ None,
+ Some(Variant::Time(
+ NaiveTime::from_num_seconds_from_midnight_opt(3600,
0).unwrap(),
+ )),
+ None,
+ ],
+ );
+ }
+
+ #[test]
+ fn test_cast_to_variant_non_strict_mode_timestamp() {
+ let ts_array = TimestampSecondArray::from(vec![Some(i64::MAX),
Some(0), Some(1609459200)])
+ .with_timezone_opt(None::<&str>);
+
+ let values = Arc::new(ts_array);
+ run_test_non_strict(
+ values,
+ vec
for context. However, I don't think it should be in this PR, we could discuss
and make them consistent later.
cc @alamb
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]