rok commented on code in PR #12657:
URL: https://github.com/apache/arrow/pull/12657#discussion_r874251775
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2632,6 +3117,129 @@ TEST_F(ScalarTemporalTest,
TestCeilFloorRoundTemporalBrussels) {
CheckScalarUnary("round_temporal", unit, times, unit, round_2_hours,
&round_to_2_hours);
}
+TEST_F(ScalarTemporalTest, TestRoundTemporalMultipleSinceGreaterUnit) {
+ std::string op = "round_temporal";
+ RoundTemporalOptions round_to_15_nanoseconds =
+ RoundTemporalOptions(15, CalendarUnit::NANOSECOND, true, true, true);
+ RoundTemporalOptions round_to_15_microseconds =
+ RoundTemporalOptions(15, CalendarUnit::MICROSECOND, true, true, true);
+ RoundTemporalOptions round_to_15_milliseconds =
+ RoundTemporalOptions(15, CalendarUnit::MILLISECOND, true, true, true);
+ RoundTemporalOptions round_to_13_seconds =
+ RoundTemporalOptions(13, CalendarUnit::SECOND, true, true, true);
+ RoundTemporalOptions round_to_13_minutes =
+ RoundTemporalOptions(13, CalendarUnit::MINUTE, true, true, true);
+ RoundTemporalOptions round_to_15_hours =
+ RoundTemporalOptions(15, CalendarUnit::HOUR, true, true, true);
+ RoundTemporalOptions round_to_15_days =
+ RoundTemporalOptions(15, CalendarUnit::DAY, true, true, true);
+ RoundTemporalOptions round_to_15_weeks =
+ RoundTemporalOptions(15, CalendarUnit::WEEK, true, true, true);
+ RoundTemporalOptions round_to_15_weeks_sunday =
+ RoundTemporalOptions(15, CalendarUnit::WEEK, false, true, true);
+ RoundTemporalOptions round_to_15_months =
+ RoundTemporalOptions(15, CalendarUnit::MONTH, true, true, true);
+ RoundTemporalOptions round_to_15_quarters =
+ RoundTemporalOptions(15, CalendarUnit::QUARTER, true, true, true);
+ RoundTemporalOptions round_to_15_years =
+ RoundTemporalOptions(15, CalendarUnit::YEAR, true, true, true);
+
+ const char* round_15_nanosecond =
+ R"(["1970-01-01 00:00:59.123456795", "2000-02-29 23:23:24.000000005",
+ "1899-01-01 00:59:20.001001000", "2033-05-18 03:33:20.000000000",
+ "2020-01-01 01:05:05.001000000", "2019-12-31 02:10:10.002000000",
+ "2019-12-30 03:15:15.003000000", "2009-12-31 04:20:20.004132000",
+ "2010-01-01 05:25:25.005321000", "2010-01-03 06:30:30.006163000",
+ "2010-01-04 07:35:35.000000000", "2006-01-01 08:40:40.000000000",
+ "2005-12-31 09:45:45.000000000", "2008-12-28 00:00:00.000000000",
+ "2008-12-29 00:00:00.000000000", "2012-01-01 01:02:03.000000000",
null])";
+ const char* round_15_microsecond =
+ R"(["1970-01-01 00:00:59.123450", "2000-02-29 23:23:24.000005",
+ "1899-01-01 00:59:20.001000", "2033-05-18 03:33:20.000000",
+ "2020-01-01 01:05:05.001000", "2019-12-31 02:10:10.002000",
+ "2019-12-30 03:15:15.003000", "2009-12-31 04:20:20.004135",
+ "2010-01-01 05:25:25.005315", "2010-01-03 06:30:30.006165",
+ "2010-01-04 07:35:35.000000", "2006-01-01 08:40:40.000000",
+ "2005-12-31 09:45:45.000000", "2008-12-28 00:00:00.000000",
+ "2008-12-29 00:00:00.000000", "2012-01-01 01:02:03.000000", null])";
+ const char* round_15_millisecond =
+ R"(["1970-01-01 00:00:59.120", "2000-02-29 23:23:24.005",
+ "1899-01-01 00:59:20.000", "2033-05-18 03:33:20.000",
+ "2020-01-01 01:05:05.000", "2019-12-31 02:10:10.000",
+ "2019-12-30 03:15:15.000", "2009-12-31 04:20:20.000",
+ "2010-01-01 05:25:25.000", "2010-01-03 06:30:30.000",
+ "2010-01-04 07:35:35.000", "2006-01-01 08:40:40.000",
+ "2005-12-31 09:45:45.000", "2008-12-28 00:00:00.000",
+ "2008-12-29 00:00:00.000", "2012-01-01 01:02:03.000", null])";
+ const char* round_13_second =
+ R"(["1970-01-01 00:01:05", "2000-02-29 23:23:26", "1899-01-01 00:59:26",
Review Comment:
This is rounding and ceil (`00:01:05`) is closer than floor (`00:00:52`) to
original `1970-01-01 00:00:59.123456795` so `00:01:05` seems ok, but I might be
missing something.
I've originally used lubridate to generate this test set, see attached.
However lubridate does not support week multiples so I verified those by hand
at some point and error is more likely.
[rounded-times.pdf](https://github.com/apache/arrow/files/8704125/rounded-times.pdf)
--
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]