pitrou commented on code in PR #12528:
URL: https://github.com/apache/arrow/pull/12528#discussion_r865932532
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2611,6 +2611,114 @@ TEST_F(ScalarTemporalTest, TestRoundTemporal) {
CheckScalarUnary(op, unit, times, unit, round_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalAmbiguous1) {
+ // Asia/Tehran switches from UTC+4:30 to UTC+3:30 on 2022-09-22 00:00:00
UTC+4:30.
+ // This causes an hour long ambiguous period in local time.
+ auto unit = timestamp(TimeUnit::MILLI, "Asia/Tehran");
+ auto options = RoundTemporalOptions(1, CalendarUnit::HOUR,
/*some_parameter=*/true);
+ const char* times = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:00:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:00:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:00:00", "2022-09-21 20:30:00", "2022-09-21 21:00:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_ceil = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:30:00", "2022-09-21 20:30:00", "2022-09-21 21:30:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_floor = R"([
+ "2022-03-21 19:30:00", "2022-03-21 19:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 18:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 19:30:00", "2022-09-21 20:30:00", "2022-09-21 20:30:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_round = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:30:00", "2022-09-21 19:30:00",
Review Comment:
Can you choose the examples so that round gives different results from both
ceil and floor? Here it seems it's just giving the same results as ceil...
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2611,6 +2611,114 @@ TEST_F(ScalarTemporalTest, TestRoundTemporal) {
CheckScalarUnary(op, unit, times, unit, round_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalAmbiguous1) {
+ // Asia/Tehran switches from UTC+4:30 to UTC+3:30 on 2022-09-22 00:00:00
UTC+4:30.
+ // This causes an hour long ambiguous period in local time.
+ auto unit = timestamp(TimeUnit::MILLI, "Asia/Tehran");
+ auto options = RoundTemporalOptions(1, CalendarUnit::HOUR,
/*some_parameter=*/true);
+ const char* times = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:00:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:00:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:00:00", "2022-09-21 20:30:00", "2022-09-21 21:00:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_ceil = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:30:00", "2022-09-21 20:30:00", "2022-09-21 21:30:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_floor = R"([
+ "2022-03-21 19:30:00", "2022-03-21 19:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 18:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 19:30:00", "2022-09-21 20:30:00", "2022-09-21 20:30:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_round = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:30:00", "2022-09-21 20:30:00", "2022-09-21 21:30:00",
+ "2022-09-21 21:30:00"])";
+
+ CheckScalarUnary("ceil_temporal", unit, times, unit, times_ceil, &options);
+ CheckScalarUnary("floor_temporal", unit, times, unit, times_floor, &options);
+ CheckScalarUnary("round_temporal", unit, times, unit, times_round, &options);
+}
+
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalAmbiguous2) {
+ // Europe/Brussels switches from UTC+2:00 to UTC+1:00 on 2022-10-25 03:00:00
UTC+2:00
+ // This causes an hour long ambiguous period in local time.
+ auto unit = timestamp(TimeUnit::NANO, "Europe/Brussels");
+ auto options = RoundTemporalOptions(15, CalendarUnit::MINUTE, true);
Review Comment:
Also add parameter name here and below...
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2611,6 +2611,114 @@ TEST_F(ScalarTemporalTest, TestRoundTemporal) {
CheckScalarUnary(op, unit, times, unit, round_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalAmbiguous1) {
+ // Asia/Tehran switches from UTC+4:30 to UTC+3:30 on 2022-09-22 00:00:00
UTC+4:30.
+ // This causes an hour long ambiguous period in local time.
Review Comment:
Thank you. Why are we also testing 2022-03-21 here?
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2611,6 +2611,114 @@ TEST_F(ScalarTemporalTest, TestRoundTemporal) {
CheckScalarUnary(op, unit, times, unit, round_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalAmbiguous1) {
+ // Asia/Tehran switches from UTC+4:30 to UTC+3:30 on 2022-09-22 00:00:00
UTC+4:30.
+ // This causes an hour long ambiguous period in local time.
+ auto unit = timestamp(TimeUnit::MILLI, "Asia/Tehran");
+ auto options = RoundTemporalOptions(1, CalendarUnit::HOUR,
/*some_parameter=*/true);
+ const char* times = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:00:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:00:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:00:00", "2022-09-21 20:30:00", "2022-09-21 21:00:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_ceil = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:30:00", "2022-09-21 20:30:00", "2022-09-21 21:30:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_floor = R"([
+ "2022-03-21 19:30:00", "2022-03-21 19:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 18:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 19:30:00", "2022-09-21 20:30:00", "2022-09-21 20:30:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_round = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:30:00", "2022-09-21 20:30:00", "2022-09-21 21:30:00",
+ "2022-09-21 21:30:00"])";
+
+ CheckScalarUnary("ceil_temporal", unit, times, unit, times_ceil, &options);
+ CheckScalarUnary("floor_temporal", unit, times, unit, times_floor, &options);
+ CheckScalarUnary("round_temporal", unit, times, unit, times_round, &options);
+}
+
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalAmbiguous2) {
+ // Europe/Brussels switches from UTC+2:00 to UTC+1:00 on 2022-10-25 03:00:00
UTC+2:00
+ // This causes an hour long ambiguous period in local time.
+ auto unit = timestamp(TimeUnit::NANO, "Europe/Brussels");
+ auto options = RoundTemporalOptions(15, CalendarUnit::MINUTE, true);
+ const char* times = R"([
+ "2018-10-28 01:05:00", "2018-10-28 01:20:00", "2018-10-28 01:55:00",
+ "2018-10-28 01:59:59", "2018-10-28 02:00:00", "2018-10-28 02:08:00"])";
+ const char* times_ceil = R"([
+ "2018-10-28 01:15:00", "2018-10-28 01:30:00", "2018-10-28 02:00:00",
+ "2018-10-28 02:00:00", "2018-10-28 02:00:00", "2018-10-28 02:15:00"])";
+ const char* times_floor = R"([
+ "2018-10-28 01:00:00", "2018-10-28 01:15:00", "2018-10-28 01:45:00",
+ "2018-10-28 01:45:00", "2018-10-28 02:00:00", "2018-10-28 02:00:00"])";
+ const char* times_round = R"([
+ "2018-10-28 01:00:00", "2018-10-28 01:15:00", "2018-10-28 02:00:00",
+ "2018-10-28 02:00:00", "2018-10-28 02:00:00", "2018-10-28 02:15:00"])";
+
+ CheckScalarUnary("ceil_temporal", unit, times, unit, times_ceil, &options);
+ CheckScalarUnary("floor_temporal", unit, times, unit, times_floor, &options);
+ CheckScalarUnary("round_temporal", unit, times, unit, times_round, &options);
+}
+
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalNonexistent1) {
+ // Asia/Tehran switches from UTC+3:30 to UTC+4:30 on 2022-03-22 00:00:00
UTC+3:30
+ // This causes an hour long non-existing period in local time.
+ auto unit = timestamp(TimeUnit::SECOND, "Asia/Tehran");
+ auto options = RoundTemporalOptions(1, CalendarUnit::HOUR, true);
+ const char* times = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:00:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:00:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:00:00", "2022-09-21 20:30:00", "2022-09-21 21:00:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_ceil = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:30:00", "2022-09-21 20:30:00", "2022-09-21 21:30:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_floor = R"([
+ "2022-03-21 19:30:00", "2022-03-21 19:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 18:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 19:30:00", "2022-09-21 20:30:00", "2022-09-21 20:30:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_round = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:30:00", "2022-03-21 20:30:00",
Review Comment:
Same here: choose the example so that round is different from both floor and
ceil?
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2611,6 +2611,114 @@ TEST_F(ScalarTemporalTest, TestRoundTemporal) {
CheckScalarUnary(op, unit, times, unit, round_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalAmbiguous1) {
+ // Asia/Tehran switches from UTC+4:30 to UTC+3:30 on 2022-09-22 00:00:00
UTC+4:30.
+ // This causes an hour long ambiguous period in local time.
+ auto unit = timestamp(TimeUnit::MILLI, "Asia/Tehran");
+ auto options = RoundTemporalOptions(1, CalendarUnit::HOUR,
/*some_parameter=*/true);
+ const char* times = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:00:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:00:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:00:00", "2022-09-21 20:30:00", "2022-09-21 21:00:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_ceil = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:30:00", "2022-09-21 20:30:00", "2022-09-21 21:30:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_floor = R"([
+ "2022-03-21 19:30:00", "2022-03-21 19:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 18:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 19:30:00", "2022-09-21 20:30:00", "2022-09-21 20:30:00",
+ "2022-09-21 21:30:00"])";
+ const char* times_round = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:30:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:30:00", "2022-09-21 19:30:00",
+ "2022-09-21 20:30:00", "2022-09-21 20:30:00", "2022-09-21 21:30:00",
+ "2022-09-21 21:30:00"])";
+
+ CheckScalarUnary("ceil_temporal", unit, times, unit, times_ceil, &options);
+ CheckScalarUnary("floor_temporal", unit, times, unit, times_floor, &options);
+ CheckScalarUnary("round_temporal", unit, times, unit, times_round, &options);
+}
+
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalAmbiguous2) {
+ // Europe/Brussels switches from UTC+2:00 to UTC+1:00 on 2022-10-25 03:00:00
UTC+2:00
+ // This causes an hour long ambiguous period in local time.
+ auto unit = timestamp(TimeUnit::NANO, "Europe/Brussels");
+ auto options = RoundTemporalOptions(15, CalendarUnit::MINUTE, true);
+ const char* times = R"([
+ "2018-10-28 01:05:00", "2018-10-28 01:20:00", "2018-10-28 01:55:00",
+ "2018-10-28 01:59:59", "2018-10-28 02:00:00", "2018-10-28 02:08:00"])";
+ const char* times_ceil = R"([
+ "2018-10-28 01:15:00", "2018-10-28 01:30:00", "2018-10-28 02:00:00",
+ "2018-10-28 02:00:00", "2018-10-28 02:00:00", "2018-10-28 02:15:00"])";
+ const char* times_floor = R"([
+ "2018-10-28 01:00:00", "2018-10-28 01:15:00", "2018-10-28 01:45:00",
+ "2018-10-28 01:45:00", "2018-10-28 02:00:00", "2018-10-28 02:00:00"])";
+ const char* times_round = R"([
+ "2018-10-28 01:00:00", "2018-10-28 01:15:00", "2018-10-28 02:00:00",
+ "2018-10-28 02:00:00", "2018-10-28 02:00:00", "2018-10-28 02:15:00"])";
+
+ CheckScalarUnary("ceil_temporal", unit, times, unit, times_ceil, &options);
+ CheckScalarUnary("floor_temporal", unit, times, unit, times_floor, &options);
+ CheckScalarUnary("round_temporal", unit, times, unit, times_round, &options);
+}
+
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalNonexistent1) {
+ // Asia/Tehran switches from UTC+3:30 to UTC+4:30 on 2022-03-22 00:00:00
UTC+3:30
+ // This causes an hour long non-existing period in local time.
+ auto unit = timestamp(TimeUnit::SECOND, "Asia/Tehran");
+ auto options = RoundTemporalOptions(1, CalendarUnit::HOUR, true);
+ const char* times = R"([
+ "2022-03-21 19:30:00", "2022-03-21 20:00:00", "2022-03-21 20:30:00",
+ "2022-09-21 18:30:00", "2022-09-21 19:00:00", "2022-09-21 19:30:00",
Review Comment:
Why are we also testing 2022-09-21 here?
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2611,6 +2611,114 @@ TEST_F(ScalarTemporalTest, TestRoundTemporal) {
CheckScalarUnary(op, unit, times, unit, round_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalAmbiguous1) {
+ // Asia/Tehran switches from UTC+4:30 to UTC+3:30 on 2022-09-22 00:00:00
UTC+4:30.
+ // This causes an hour long ambiguous period in local time.
+ auto unit = timestamp(TimeUnit::MILLI, "Asia/Tehran");
+ auto options = RoundTemporalOptions(1, CalendarUnit::HOUR,
/*some_parameter=*/true);
Review Comment:
Can you put the proper parameter name? :-)
--
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]