You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/29 11:55:42 UTC
[GitHub] [arrow] rok opened a new pull request, #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
rok opened a new pull request, #13462:
URL: https://github.com/apache/arrow/pull/13462
When rounding to some calendar units the result will be offset in UTC instead of the local timezone. [See discussion](https://github.com/apache/arrow/pull/12154#issuecomment-1169578666).
This adds a fix and C++ test cases.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
pitrou commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913090391
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -409,6 +409,60 @@ class ScalarTemporalTest : public ::testing::Test {
RoundTemporalOptions(15, CalendarUnit::QUARTER);
RoundTemporalOptions round_to_15_years = RoundTemporalOptions(15, CalendarUnit::YEAR);
+ RoundTemporalOptions round_to_1_nanoseconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::NANOSECOND, true, true, false);
Review Comment:
Hmm... to avoid the naming issue, perhaps we can have a derived fixture for `ceil_is_strictly_greater = true`?
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -409,6 +409,60 @@ class ScalarTemporalTest : public ::testing::Test {
RoundTemporalOptions(15, CalendarUnit::QUARTER);
RoundTemporalOptions round_to_15_years = RoundTemporalOptions(15, CalendarUnit::YEAR);
+ RoundTemporalOptions round_to_1_nanoseconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::NANOSECOND, true, true, false);
+ RoundTemporalOptions round_to_1_microseconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::MICROSECOND, true, true, false);
+ RoundTemporalOptions round_to_1_milliseconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::MILLISECOND, true, true, false);
+ RoundTemporalOptions round_to_1_seconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::SECOND, true, true, false);
+ RoundTemporalOptions round_to_1_minutes_2 =
+ RoundTemporalOptions(1, CalendarUnit::MINUTE, true, true, false);
+ RoundTemporalOptions round_to_1_hours_2 =
+ RoundTemporalOptions(1, CalendarUnit::HOUR, true, true, false);
+ RoundTemporalOptions round_to_1_days_2 =
+ RoundTemporalOptions(1, CalendarUnit::DAY, true, true, false);
+ RoundTemporalOptions round_to_1_weeks_2 =
+ RoundTemporalOptions(1, CalendarUnit::WEEK, true, true, false);
+ RoundTemporalOptions round_to_1_weeks_sunday_2 =
+ RoundTemporalOptions(1, CalendarUnit::WEEK, false, true, false);
+ RoundTemporalOptions round_to_1_months_2 =
+ RoundTemporalOptions(1, CalendarUnit::MONTH, true, true, false);
+ RoundTemporalOptions round_to_1_quarters_2 =
+ RoundTemporalOptions(1, CalendarUnit::QUARTER, true, true, false);
+ RoundTemporalOptions round_to_1_years_2 =
+ RoundTemporalOptions(1, CalendarUnit::YEAR, true, true, false);
+
+ RoundTemporalOptions round_to_15_nanoseconds_2 =
Review Comment:
Similar suggestion here for `calendar_based_origin = true`.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
pitrou commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913899174
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -409,6 +409,60 @@ class ScalarTemporalTest : public ::testing::Test {
RoundTemporalOptions(15, CalendarUnit::QUARTER);
RoundTemporalOptions round_to_15_years = RoundTemporalOptions(15, CalendarUnit::YEAR);
+ RoundTemporalOptions round_to_1_nanoseconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::NANOSECOND, true, true, false);
Review Comment:
Thanks... why is `calendar_based_origin` false here? Am I misreading? Or are these unused?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] rok commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
rok commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913070905
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -3249,6 +3493,128 @@ TEST_F(ScalarTemporalTest, TestRoundTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, round_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestRoundTemporalMultipleSinceGreaterUnitZoned) {
+ 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_5_months =
+ RoundTemporalOptions(5, CalendarUnit::MONTH, true, true, true);
+ RoundTemporalOptions round_to_3_quarters =
+ RoundTemporalOptions(3, CalendarUnit::QUARTER, true, true, true);
+ RoundTemporalOptions round_to_15_years =
+ RoundTemporalOptions(15, CalendarUnit::YEAR, true, true, true);
+
+ // Data for tests below was generaed via lubridate with the exception
+ // of week data because lubridate currently does not support rounding to
+ // multiple of week.
+ 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", "2033-05-18 03:33:26",
+ "2020-01-01 01:05:00", "2019-12-31 02:10:13", "2019-12-30 03:15:13", "2009-12-31 04:20:26",
+ "2010-01-01 05:25:26", "2010-01-03 06:30:26", "2010-01-04 07:35:39", "2006-01-01 08:40:39",
+ "2005-12-31 09:45:39", "2008-12-28 00:00:00", "2008-12-29 00:00:00", "2012-01-01 01:02:00", null])";
+ const char* round_13_minute = R"([
+ "1969-12-31 23:56:00", "2000-02-29 23:22:00", "1899-01-01 01:05:00", "2033-05-18 03:30:00",
+ "2020-01-01 01:09:00", "2019-12-31 02:09:00", "2019-12-30 03:09:00", "2009-12-31 04:22:00",
+ "2010-01-01 05:22:00", "2010-01-03 06:30:00", "2010-01-04 07:30:00", "2006-01-01 08:43:00",
+ "2005-12-31 09:43:00", "2008-12-27 23:56:00", "2008-12-28 23:56:00", "2012-01-01 00:56:00", null])";
+ const char* round_15_hour = R"([
+ "1970-01-01 05:30:00", "2000-03-01 04:30:00", "1899-01-01 06:00:00", "2033-05-18 05:30:00",
+ "2020-01-01 04:30:00", "2019-12-31 04:30:00", "2019-12-30 04:30:00", "2009-12-31 04:30:00",
+ "2010-01-01 04:30:00", "2010-01-03 04:30:00", "2010-01-04 04:30:00", "2006-01-01 04:30:00",
+ "2005-12-31 04:30:00", "2008-12-28 04:30:00", "2008-12-29 04:30:00", "2012-01-01 04:30:00", null])";
+ const char* round_15_day = R"([
+ "1969-12-31 14:30:00", "2000-02-29 13:30:00", "1898-12-31 15:00:00", "2033-05-15 14:30:00",
+ "2019-12-31 13:30:00", "2019-12-30 13:30:00", "2019-12-30 13:30:00", "2009-12-30 13:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2005-12-31 13:30:00",
+ "2005-12-30 13:30:00", "2008-12-30 13:30:00", "2008-12-30 13:30:00", "2011-12-31 13:30:00", null])";
+ const char* round_15_weeks = R"([
+ "1969-12-28 14:30:00", "2000-04-16 14:30:00", "1899-01-01 15:00:00", "2033-04-17 14:30:00",
+ "2019-12-29 13:30:00", "2019-12-29 13:30:00", "2019-12-29 13:30:00", "2010-01-03 13:30:00",
+ "2010-01-03 13:30:00", "2010-01-03 13:30:00", "2010-01-03 13:30:00", "2006-01-01 13:30:00",
+ "2006-01-01 13:30:00", "2008-11-09 13:30:00", "2008-12-28 13:30:00", "2012-01-01 13:30:00", null])";
+ const char* round_15_weeks_sunday = R"([
+ "1970-01-03 14:30:00", "2000-04-15 14:30:00", "1898-12-31 15:00:00", "2033-04-16 14:30:00",
+ "2019-12-28 13:30:00", "2019-12-28 13:30:00", "2019-12-28 13:30:00", "2010-01-02 13:30:00",
+ "2010-01-02 13:30:00", "2010-01-02 13:30:00", "2010-01-02 13:30:00", "2005-12-31 13:30:00",
+ "2005-12-31 13:30:00", "2009-01-03 13:30:00", "2009-01-03 13:30:00", "2011-12-31 13:30:00", null])";
+ const char* round_5_months = R"([
+ "1969-12-31 14:30:00", "1999-12-31 13:30:00", "1898-12-31 15:00:00", "2033-05-31 14:30:00",
+ "2019-12-31 13:30:00", "2019-10-31 13:30:00", "2019-10-31 13:30:00", "2009-10-31 13:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2005-12-31 13:30:00",
+ "2005-10-31 13:30:00", "2008-10-31 13:30:00", "2008-10-31 13:30:00", "2011-12-31 13:30:00", null])";
+ const char* round_3_quarters = R"([
+ "1969-12-31 14:30:00", "1999-12-31 13:30:00", "1898-12-31 15:00:00", "2033-09-30 14:30:00",
+ "2019-12-31 13:30:00", "2019-09-30 14:30:00", "2019-09-30 14:30:00", "2009-09-30 14:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2005-12-31 13:30:00",
+ "2005-09-30 14:30:00", "2008-09-30 14:30:00", "2008-09-30 14:30:00", "2011-12-31 13:30:00", null])";
+ const char* round_15_years = R"([
+ "1964-12-31 14:30:00", "1994-12-31 13:30:00", "1904-12-31 14:30:00", "2039-12-31 13:30:00",
+ "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2009-12-31 13:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", null])";
+ auto unit = timestamp(TimeUnit::NANO, "Australia/Broken_Hill");
Review Comment:
```suggestion
// Australia/Broken_Hill timezone is defined as UTC+9:30 and UTC+10:30 during DST.
// DST runs from first Sunday in October to first Sunday in April.
auto unit = timestamp(TimeUnit::NANO, "Australia/Broken_Hill");
```
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2911,6 +3032,129 @@ TEST_F(ScalarTemporalTest, TestFloorTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, floor_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestFloorTemporalMultipleSinceGreaterUnitZoned) {
+ std::string op = "floor_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_5_months =
+ RoundTemporalOptions(5, CalendarUnit::MONTH, true, true, true);
+ RoundTemporalOptions round_to_3_quarters =
+ RoundTemporalOptions(3, CalendarUnit::QUARTER, true, true, true);
+ RoundTemporalOptions round_to_15_years =
+ RoundTemporalOptions(15, CalendarUnit::YEAR, true, true, true);
+
+ // Data for tests below was generaed via lubridate with the exception
+ // of week data because lubridate currently does not support rounding to
+ // multiple of week.
+ const char* floor_15_nanosecond =
+ R"(["1970-01-01 00:00:59.123456780", "2000-02-29 23:23:23.999999990",
+ "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* floor_15_microsecond =
+ R"(["1970-01-01 00:00:59.123450", "2000-02-29 23:23:23.999990",
+ "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.004120",
+ "2010-01-01 05:25:25.005315", "2010-01-03 06:30:30.006150",
+ "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* floor_15_millisecond =
+ R"(["1970-01-01 00:00:59.120", "2000-02-29 23:23:23.990",
+ "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* floor_13_second = R"([
+ "1970-01-01 00:00:52", "2000-02-29 23:23:13", "1899-01-01 00:59:13", "2033-05-18 03:33:13",
+ "2020-01-01 01:05:00", "2019-12-31 02:10:00", "2019-12-30 03:15:13", "2009-12-31 04:20:13",
+ "2010-01-01 05:25:13", "2010-01-03 06:30:26", "2010-01-04 07:35:26", "2006-01-01 08:40:39",
+ "2005-12-31 09:45:39", "2008-12-28 00:00:00", "2008-12-29 00:00:00", "2012-01-01 01:02:00", null])";
+ const char* floor_13_minute = R"([
+ "1969-12-31 23:56:00", "2000-02-29 23:22:00", "1899-01-01 00:52:00", "2033-05-18 03:30:00",
+ "2020-01-01 00:56:00", "2019-12-31 02:09:00", "2019-12-30 03:09:00", "2009-12-31 04:09:00",
+ "2010-01-01 05:22:00", "2010-01-03 06:30:00", "2010-01-04 07:30:00", "2006-01-01 08:30:00",
+ "2005-12-31 09:43:00", "2008-12-27 23:56:00", "2008-12-28 23:56:00", "2012-01-01 00:56:00", null])";
+ const char* floor_15_hour = R"([
+ "1969-12-31 14:30:00", "2000-02-29 13:30:00", "1898-12-31 15:00:00", "2033-05-17 14:30:00",
+ "2019-12-31 13:30:00", "2019-12-30 13:30:00", "2019-12-29 13:30:00", "2009-12-30 13:30:00",
+ "2010-01-01 04:30:00", "2010-01-03 04:30:00", "2010-01-04 04:30:00", "2006-01-01 04:30:00",
+ "2005-12-31 04:30:00", "2008-12-27 13:30:00", "2008-12-28 13:30:00", "2011-12-31 13:30:00", null])";
+ const char* floor_15_day = R"([
+ "1969-12-31 14:30:00", "2000-02-29 13:30:00", "1898-12-31 15:00:00", "2033-05-15 14:30:00",
+ "2019-12-31 13:30:00", "2019-12-30 13:30:00", "2019-12-15 13:30:00", "2009-12-30 13:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2005-12-31 13:30:00",
+ "2005-12-30 13:30:00", "2008-12-15 13:30:00", "2008-12-15 13:30:00", "2011-12-31 13:30:00", null])";
+ const char* floor_15_weeks = R"([
+ "1969-12-28 14:30:00", "2000-01-02 13:30:00", "1899-01-01 15:00:00", "2033-04-17 14:30:00",
+ "2019-12-29 13:30:00", "2019-12-29 13:30:00", "2019-12-29 13:30:00", "2010-01-03 13:30:00",
+ "2010-01-03 13:30:00", "2010-01-03 13:30:00", "2010-01-03 13:30:00", "2006-01-01 13:30:00",
+ "2006-01-01 13:30:00", "2008-11-09 13:30:00", "2008-12-28 13:30:00", "2012-01-01 13:30:00", null])";
+ const char* floor_15_weeks_sunday = R"([
+ "1970-01-03 14:30:00", "2000-01-01 13:30:00", "1898-12-31 15:00:00", "2033-04-16 14:30:00",
+ "2019-12-28 13:30:00", "2019-12-28 13:30:00", "2019-12-28 13:30:00", "2010-01-02 13:30:00",
+ "2010-01-02 13:30:00", "2010-01-02 13:30:00", "2010-01-02 13:30:00", "2005-12-31 13:30:00",
+ "2005-12-31 13:30:00", "2009-01-03 13:30:00", "2009-01-03 13:30:00", "2011-12-31 13:30:00", null])";
+ const char* floor_5_months = R"([
+ "1969-12-31 14:30:00", "1999-12-31 13:30:00", "1898-12-31 15:00:00", "2032-12-31 13:30:00",
+ "2019-12-31 13:30:00", "2019-10-31 13:30:00", "2019-10-31 13:30:00", "2009-10-31 13:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2005-12-31 13:30:00",
+ "2005-10-31 13:30:00", "2008-10-31 13:30:00", "2008-10-31 13:30:00", "2011-12-31 13:30:00", null])";
+ const char* floor_3_quarters = R"([
+ "1969-12-31 14:30:00", "1999-12-31 13:30:00", "1898-12-31 15:00:00", "2032-12-31 13:30:00",
+ "2019-12-31 13:30:00", "2019-09-30 14:30:00", "2019-09-30 14:30:00", "2009-09-30 14:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2005-12-31 13:30:00",
+ "2005-09-30 14:30:00", "2008-09-30 14:30:00", "2008-09-30 14:30:00", "2011-12-31 13:30:00", null])";
+ const char* floor_15_years = R"([
+ "1964-12-31 14:30:00", "1994-12-31 13:30:00", "1889-12-31 14:34:12", "2024-12-31 13:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "1994-12-31 13:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "1994-12-31 13:30:00",
+ "1994-12-31 13:30:00", "1994-12-31 13:30:00", "1994-12-31 13:30:00", "2009-12-31 13:30:00", null])";
+
+ auto unit = timestamp(TimeUnit::NANO, "Australia/Broken_Hill");
Review Comment:
```suggestion
// Australia/Broken_Hill timezone is defined as UTC+9:30 and UTC+10:30 during DST.
// DST runs from first Sunday in October to first Sunday in April.
auto unit = timestamp(TimeUnit::NANO, "Australia/Broken_Hill");
```
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2593,6 +2593,127 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnitZoned) {
+ std::string op = "ceil_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_5_months =
+ RoundTemporalOptions(5, CalendarUnit::MONTH, true, true, true);
+ RoundTemporalOptions round_to_3_quarters =
+ RoundTemporalOptions(3, CalendarUnit::QUARTER, true, true, true);
+ RoundTemporalOptions round_to_15_years =
+ RoundTemporalOptions(15, CalendarUnit::YEAR, true, true, true);
+
+ // Data for tests below was generaed via lubridate with the exception
+ // of week data because lubridate currently does not support rounding to
+ // multiple of week.
+ const char* ceil_15_nanosecond =
+ R"(["1970-01-01 00:00:59.123456795", "2000-02-29 23:23:24.000000005",
+ "1899-01-01 00:59:20.001001015", "2033-05-18 03:33:20.000000015",
+ "2020-01-01 01:05:05.001000015", "2019-12-31 02:10:10.002000015",
+ "2019-12-30 03:15:15.003000015", "2009-12-31 04:20:20.004132015",
+ "2010-01-01 05:25:25.005321015", "2010-01-03 06:30:30.006163015",
+ "2010-01-04 07:35:35.000000015", "2006-01-01 08:40:40.000000015",
+ "2005-12-31 09:45:45.000000015", "2008-12-28 00:00:00.000000015",
+ "2008-12-29 00:00:00.000000015", "2012-01-01 01:02:03.000000015", null])";
+ const char* ceil_15_microsecond =
+ R"(["1970-01-01 00:00:59.123465", "2000-02-29 23:23:24.000005",
+ "1899-01-01 00:59:20.001015", "2033-05-18 03:33:20.000015",
+ "2020-01-01 01:05:05.001015", "2019-12-31 02:10:10.002015",
+ "2019-12-30 03:15:15.003015", "2009-12-31 04:20:20.004135",
+ "2010-01-01 05:25:25.005330", "2010-01-03 06:30:30.006165",
+ "2010-01-04 07:35:35.000015", "2006-01-01 08:40:40.000015",
+ "2005-12-31 09:45:45.000015", "2008-12-28 00:00:00.000015",
+ "2008-12-29 00:00:00.000015", "2012-01-01 01:02:03.000015", null])";
+ const char* ceil_15_millisecond =
+ R"(["1970-01-01 00:00:59.135", "2000-02-29 23:23:24.005",
+ "1899-01-01 00:59:20.015", "2033-05-18 03:33:20.015",
+ "2020-01-01 01:05:05.015", "2019-12-31 02:10:10.015",
+ "2019-12-30 03:15:15.015", "2009-12-31 04:20:20.015",
+ "2010-01-01 05:25:25.015", "2010-01-03 06:30:30.015",
+ "2010-01-04 07:35:35.015", "2006-01-01 08:40:40.015",
+ "2005-12-31 09:45:45.015", "2008-12-28 00:00:00.015",
+ "2008-12-29 00:00:00.015", "2012-01-01 01:02:03.015", null])";
+ const char* ceil_13_second = R"([
+ "1970-01-01 00:01:05", "2000-02-29 23:23:26", "1899-01-01 00:59:26", "2033-05-18 03:33:26",
+ "2020-01-01 01:05:13", "2019-12-31 02:10:13", "2019-12-30 03:15:26", "2009-12-31 04:20:26",
+ "2010-01-01 05:25:26", "2010-01-03 06:30:39", "2010-01-04 07:35:39", "2006-01-01 08:40:52",
+ "2005-12-31 09:45:52", "2008-12-28 00:00:13", "2008-12-29 00:00:13", "2012-01-01 01:02:13", null])";
+ const char* ceil_13_minute = R"([
+ "1970-01-01 00:09:00", "2000-02-29 23:35:00", "1899-01-01 01:05:00", "2033-05-18 03:43:00",
+ "2020-01-01 01:09:00", "2019-12-31 02:22:00", "2019-12-30 03:22:00", "2009-12-31 04:22:00",
+ "2010-01-01 05:35:00", "2010-01-03 06:43:00", "2010-01-04 07:43:00", "2006-01-01 08:43:00",
+ "2005-12-31 09:56:00", "2008-12-28 00:09:00", "2008-12-29 00:09:00", "2012-01-01 01:09:00", null])";
+ const char* ceil_15_hour = R"([
+ "1970-01-01 05:30:00", "2000-03-01 04:30:00", "1899-01-01 06:00:00", "2033-05-18 05:30:00",
+ "2020-01-01 04:30:00", "2019-12-31 04:30:00", "2019-12-30 04:30:00", "2009-12-31 04:30:00",
+ "2010-01-01 19:30:00", "2010-01-03 19:30:00", "2010-01-04 19:30:00", "2006-01-01 19:30:00",
+ "2005-12-31 19:30:00", "2008-12-28 04:30:00", "2008-12-29 04:30:00", "2012-01-01 04:30:00", null])";
+ const char* ceil_15_day = R"([
+ "1970-01-15 14:30:00", "2000-03-15 13:30:00", "1899-01-15 15:00:00", "2033-05-30 14:30:00",
+ "2020-01-15 13:30:00", "2020-01-14 13:30:00", "2019-12-30 13:30:00", "2010-01-14 13:30:00",
+ "2010-01-15 13:30:00", "2010-01-15 13:30:00", "2010-01-15 13:30:00", "2006-01-15 13:30:00",
+ "2006-01-14 13:30:00", "2008-12-30 13:30:00", "2008-12-30 13:30:00", "2012-01-15 13:30:00", null])";
+ const char* ceil_15_weeks = R"([
+ "1970-04-12 14:30:00", "2000-04-16 14:30:00", "1899-04-16 15:00:00", "2033-07-31 14:30:00",
+ "2020-04-12 14:30:00", "2020-04-12 14:30:00", "2020-04-12 14:30:00", "2010-04-18 14:30:00",
+ "2010-04-18 14:30:00", "2010-04-18 14:30:00", "2010-04-18 14:30:00", "2006-04-16 14:30:00",
+ "2006-04-16 14:30:00", "2009-02-22 13:30:00", "2009-04-12 14:30:00", "2012-04-15 14:30:00", null])";
+ const char* ceil_15_weeks_sunday = R"([
+ "1970-04-18 14:30:00", "2000-04-15 14:30:00", "1899-04-15 15:00:00", "2033-07-30 14:30:00",
+ "2020-04-11 14:30:00", "2020-04-11 14:30:00", "2020-04-11 14:30:00", "2010-04-17 14:30:00",
+ "2010-04-17 14:30:00", "2010-04-17 14:30:00", "2010-04-17 14:30:00", "2006-04-15 14:30:00",
+ "2006-04-15 14:30:00", "2009-04-18 14:30:00", "2009-04-18 14:30:00", "2012-04-14 14:30:00", null])";
+ const char* ceil_5_months = R"([
+ "1970-05-31 14:30:00", "2000-05-31 14:30:00", "1899-05-31 14:30:00", "2033-05-31 14:30:00",
+ "2020-05-31 14:30:00", "2020-03-31 13:30:00", "2020-03-31 13:30:00", "2010-03-31 13:30:00",
+ "2010-05-31 14:30:00", "2010-05-31 14:30:00", "2010-05-31 14:30:00", "2006-05-31 14:30:00",
+ "2006-03-31 13:30:00", "2009-03-31 13:30:00", "2009-03-31 13:30:00", "2012-05-31 14:30:00", null])";
+ const char* ceil_3_quarters = R"([
+ "1970-09-30 14:30:00", "2000-09-30 14:30:00", "1899-09-30 14:30:00", "2033-09-30 14:30:00",
+ "2020-09-30 14:30:00", "2020-06-30 14:30:00", "2020-06-30 14:30:00", "2010-06-30 14:30:00",
+ "2010-09-30 14:30:00", "2010-09-30 14:30:00", "2010-09-30 14:30:00", "2006-09-30 14:30:00",
+ "2006-06-30 14:30:00", "2009-06-30 14:30:00", "2009-06-30 14:30:00", "2012-09-30 14:30:00", null])";
+ const char* ceil_15_years = R"([
+ "1979-12-31 13:30:00", "2009-12-31 13:30:00", "1904-12-31 14:30:00", "2039-12-31 13:30:00",
+ "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2009-12-31 13:30:00",
+ "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2009-12-31 13:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2024-12-31 13:30:00", null])";
+
+ auto unit = timestamp(TimeUnit::NANO, "Australia/Broken_Hill");
Review Comment:
```suggestion
// Australia/Broken_Hill timezone is defined as UTC+9:30 and UTC+10:30 during DST.
// DST runs from first Sunday in October to first Sunday in April.
auto unit = timestamp(TimeUnit::NANO, "Australia/Broken_Hill");
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
pitrou commented on PR #13462:
URL: https://github.com/apache/arrow/pull/13462#issuecomment-1175233697
Cool, thanks for the persistence :-)
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] rok commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
rok commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913062215
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2593,6 +2593,127 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnitZoned) {
+ std::string op = "ceil_temporal";
+ RoundTemporalOptions round_to_15_nanoseconds =
Review Comment:
Hm, yeah that might be a nice idea. Let me check.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou merged pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
pitrou merged PR #13462:
URL: https://github.com/apache/arrow/pull/13462
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] rok commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
rok commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913071539
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2593,6 +2593,127 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnitZoned) {
+ std::string op = "ceil_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_5_months =
+ RoundTemporalOptions(5, CalendarUnit::MONTH, true, true, true);
+ RoundTemporalOptions round_to_3_quarters =
+ RoundTemporalOptions(3, CalendarUnit::QUARTER, true, true, true);
+ RoundTemporalOptions round_to_15_years =
+ RoundTemporalOptions(15, CalendarUnit::YEAR, true, true, true);
+
+ // Data for tests below was generaed via lubridate with the exception
+ // of week data because lubridate currently does not support rounding to
+ // multiple of week.
+ const char* ceil_15_nanosecond =
+ R"(["1970-01-01 00:00:59.123456795", "2000-02-29 23:23:24.000000005",
+ "1899-01-01 00:59:20.001001015", "2033-05-18 03:33:20.000000015",
+ "2020-01-01 01:05:05.001000015", "2019-12-31 02:10:10.002000015",
+ "2019-12-30 03:15:15.003000015", "2009-12-31 04:20:20.004132015",
+ "2010-01-01 05:25:25.005321015", "2010-01-03 06:30:30.006163015",
+ "2010-01-04 07:35:35.000000015", "2006-01-01 08:40:40.000000015",
+ "2005-12-31 09:45:45.000000015", "2008-12-28 00:00:00.000000015",
+ "2008-12-29 00:00:00.000000015", "2012-01-01 01:02:03.000000015", null])";
+ const char* ceil_15_microsecond =
+ R"(["1970-01-01 00:00:59.123465", "2000-02-29 23:23:24.000005",
+ "1899-01-01 00:59:20.001015", "2033-05-18 03:33:20.000015",
+ "2020-01-01 01:05:05.001015", "2019-12-31 02:10:10.002015",
+ "2019-12-30 03:15:15.003015", "2009-12-31 04:20:20.004135",
+ "2010-01-01 05:25:25.005330", "2010-01-03 06:30:30.006165",
+ "2010-01-04 07:35:35.000015", "2006-01-01 08:40:40.000015",
+ "2005-12-31 09:45:45.000015", "2008-12-28 00:00:00.000015",
+ "2008-12-29 00:00:00.000015", "2012-01-01 01:02:03.000015", null])";
+ const char* ceil_15_millisecond =
+ R"(["1970-01-01 00:00:59.135", "2000-02-29 23:23:24.005",
+ "1899-01-01 00:59:20.015", "2033-05-18 03:33:20.015",
+ "2020-01-01 01:05:05.015", "2019-12-31 02:10:10.015",
+ "2019-12-30 03:15:15.015", "2009-12-31 04:20:20.015",
+ "2010-01-01 05:25:25.015", "2010-01-03 06:30:30.015",
+ "2010-01-04 07:35:35.015", "2006-01-01 08:40:40.015",
+ "2005-12-31 09:45:45.015", "2008-12-28 00:00:00.015",
+ "2008-12-29 00:00:00.015", "2012-01-01 01:02:03.015", null])";
+ const char* ceil_13_second = R"([
+ "1970-01-01 00:01:05", "2000-02-29 23:23:26", "1899-01-01 00:59:26", "2033-05-18 03:33:26",
+ "2020-01-01 01:05:13", "2019-12-31 02:10:13", "2019-12-30 03:15:26", "2009-12-31 04:20:26",
+ "2010-01-01 05:25:26", "2010-01-03 06:30:39", "2010-01-04 07:35:39", "2006-01-01 08:40:52",
+ "2005-12-31 09:45:52", "2008-12-28 00:00:13", "2008-12-29 00:00:13", "2012-01-01 01:02:13", null])";
+ const char* ceil_13_minute = R"([
+ "1970-01-01 00:09:00", "2000-02-29 23:35:00", "1899-01-01 01:05:00", "2033-05-18 03:43:00",
+ "2020-01-01 01:09:00", "2019-12-31 02:22:00", "2019-12-30 03:22:00", "2009-12-31 04:22:00",
+ "2010-01-01 05:35:00", "2010-01-03 06:43:00", "2010-01-04 07:43:00", "2006-01-01 08:43:00",
+ "2005-12-31 09:56:00", "2008-12-28 00:09:00", "2008-12-29 00:09:00", "2012-01-01 01:09:00", null])";
+ const char* ceil_15_hour = R"([
+ "1970-01-01 05:30:00", "2000-03-01 04:30:00", "1899-01-01 06:00:00", "2033-05-18 05:30:00",
+ "2020-01-01 04:30:00", "2019-12-31 04:30:00", "2019-12-30 04:30:00", "2009-12-31 04:30:00",
+ "2010-01-01 19:30:00", "2010-01-03 19:30:00", "2010-01-04 19:30:00", "2006-01-01 19:30:00",
+ "2005-12-31 19:30:00", "2008-12-28 04:30:00", "2008-12-29 04:30:00", "2012-01-01 04:30:00", null])";
+ const char* ceil_15_day = R"([
+ "1970-01-15 14:30:00", "2000-03-15 13:30:00", "1899-01-15 15:00:00", "2033-05-30 14:30:00",
+ "2020-01-15 13:30:00", "2020-01-14 13:30:00", "2019-12-30 13:30:00", "2010-01-14 13:30:00",
+ "2010-01-15 13:30:00", "2010-01-15 13:30:00", "2010-01-15 13:30:00", "2006-01-15 13:30:00",
+ "2006-01-14 13:30:00", "2008-12-30 13:30:00", "2008-12-30 13:30:00", "2012-01-15 13:30:00", null])";
+ const char* ceil_15_weeks = R"([
+ "1970-04-12 14:30:00", "2000-04-16 14:30:00", "1899-04-16 15:00:00", "2033-07-31 14:30:00",
+ "2020-04-12 14:30:00", "2020-04-12 14:30:00", "2020-04-12 14:30:00", "2010-04-18 14:30:00",
+ "2010-04-18 14:30:00", "2010-04-18 14:30:00", "2010-04-18 14:30:00", "2006-04-16 14:30:00",
+ "2006-04-16 14:30:00", "2009-02-22 13:30:00", "2009-04-12 14:30:00", "2012-04-15 14:30:00", null])";
+ const char* ceil_15_weeks_sunday = R"([
+ "1970-04-18 14:30:00", "2000-04-15 14:30:00", "1899-04-15 15:00:00", "2033-07-30 14:30:00",
+ "2020-04-11 14:30:00", "2020-04-11 14:30:00", "2020-04-11 14:30:00", "2010-04-17 14:30:00",
+ "2010-04-17 14:30:00", "2010-04-17 14:30:00", "2010-04-17 14:30:00", "2006-04-15 14:30:00",
+ "2006-04-15 14:30:00", "2009-04-18 14:30:00", "2009-04-18 14:30:00", "2012-04-14 14:30:00", null])";
+ const char* ceil_5_months = R"([
+ "1970-05-31 14:30:00", "2000-05-31 14:30:00", "1899-05-31 14:30:00", "2033-05-31 14:30:00",
+ "2020-05-31 14:30:00", "2020-03-31 13:30:00", "2020-03-31 13:30:00", "2010-03-31 13:30:00",
+ "2010-05-31 14:30:00", "2010-05-31 14:30:00", "2010-05-31 14:30:00", "2006-05-31 14:30:00",
+ "2006-03-31 13:30:00", "2009-03-31 13:30:00", "2009-03-31 13:30:00", "2012-05-31 14:30:00", null])";
+ const char* ceil_3_quarters = R"([
+ "1970-09-30 14:30:00", "2000-09-30 14:30:00", "1899-09-30 14:30:00", "2033-09-30 14:30:00",
+ "2020-09-30 14:30:00", "2020-06-30 14:30:00", "2020-06-30 14:30:00", "2010-06-30 14:30:00",
+ "2010-09-30 14:30:00", "2010-09-30 14:30:00", "2010-09-30 14:30:00", "2006-09-30 14:30:00",
+ "2006-06-30 14:30:00", "2009-06-30 14:30:00", "2009-06-30 14:30:00", "2012-09-30 14:30:00", null])";
+ const char* ceil_15_years = R"([
+ "1979-12-31 13:30:00", "2009-12-31 13:30:00", "1904-12-31 14:30:00", "2039-12-31 13:30:00",
+ "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2009-12-31 13:30:00",
+ "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2009-12-31 13:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2024-12-31 13:30:00", null])";
+
+ auto unit = timestamp(TimeUnit::NANO, "Australia/Broken_Hill");
Review Comment:
Added.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] rok commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
rok commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913957782
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -409,6 +409,60 @@ class ScalarTemporalTest : public ::testing::Test {
RoundTemporalOptions(15, CalendarUnit::QUARTER);
RoundTemporalOptions round_to_15_years = RoundTemporalOptions(15, CalendarUnit::YEAR);
+ RoundTemporalOptions round_to_1_nanoseconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::NANOSECOND, true, true, false);
Review Comment:
Oh that was wrong. Fixed.
The reason the tests passed is because the error (`calendar_based_origin=true`) was only there for `multiple=1` which would return (mostly) equal for `calendar_based_origin=true` or `calendar_based_origin=false`.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] rok commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
rok commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913086537
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2593,6 +2593,127 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnitZoned) {
+ std::string op = "ceil_temporal";
+ RoundTemporalOptions round_to_15_nanoseconds =
Review Comment:
Moved to fixture. Names are not very inspired (`round_to_13_seconds` vs `round_to_13_seconds_2`).
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] rok commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
rok commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913242557
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -409,6 +409,60 @@ class ScalarTemporalTest : public ::testing::Test {
RoundTemporalOptions(15, CalendarUnit::QUARTER);
RoundTemporalOptions round_to_15_years = RoundTemporalOptions(15, CalendarUnit::YEAR);
+ RoundTemporalOptions round_to_1_nanoseconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::NANOSECOND, true, true, false);
Review Comment:
Yes! Done.
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -409,6 +409,60 @@ class ScalarTemporalTest : public ::testing::Test {
RoundTemporalOptions(15, CalendarUnit::QUARTER);
RoundTemporalOptions round_to_15_years = RoundTemporalOptions(15, CalendarUnit::YEAR);
+ RoundTemporalOptions round_to_1_nanoseconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::NANOSECOND, true, true, false);
+ RoundTemporalOptions round_to_1_microseconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::MICROSECOND, true, true, false);
+ RoundTemporalOptions round_to_1_milliseconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::MILLISECOND, true, true, false);
+ RoundTemporalOptions round_to_1_seconds_2 =
+ RoundTemporalOptions(1, CalendarUnit::SECOND, true, true, false);
+ RoundTemporalOptions round_to_1_minutes_2 =
+ RoundTemporalOptions(1, CalendarUnit::MINUTE, true, true, false);
+ RoundTemporalOptions round_to_1_hours_2 =
+ RoundTemporalOptions(1, CalendarUnit::HOUR, true, true, false);
+ RoundTemporalOptions round_to_1_days_2 =
+ RoundTemporalOptions(1, CalendarUnit::DAY, true, true, false);
+ RoundTemporalOptions round_to_1_weeks_2 =
+ RoundTemporalOptions(1, CalendarUnit::WEEK, true, true, false);
+ RoundTemporalOptions round_to_1_weeks_sunday_2 =
+ RoundTemporalOptions(1, CalendarUnit::WEEK, false, true, false);
+ RoundTemporalOptions round_to_1_months_2 =
+ RoundTemporalOptions(1, CalendarUnit::MONTH, true, true, false);
+ RoundTemporalOptions round_to_1_quarters_2 =
+ RoundTemporalOptions(1, CalendarUnit::QUARTER, true, true, false);
+ RoundTemporalOptions round_to_1_years_2 =
+ RoundTemporalOptions(1, CalendarUnit::YEAR, true, true, false);
+
+ RoundTemporalOptions round_to_15_nanoseconds_2 =
Review Comment:
Done.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] rok commented on pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
rok commented on PR #13462:
URL: https://github.com/apache/arrow/pull/13462#issuecomment-1173887911
Thanks for the review @pitrou !
> I'm unable to verify that the test values are ok, but the computational changes make sense.
Correctness of logic and (by transitive relation) tests data will be checked against lubridate here #12154.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
pitrou commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913900927
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2460,40 +2525,16 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalStrictCeil) {
CheckScalarUnary(op, unit, times, unit, ceil_13_minute, &round_to_13_minutes);
CheckScalarUnary(op, unit, times, unit, ceil_15_hour, &round_to_15_hours);
CheckScalarUnary(op, unit, times, unit, ceil_15_day, &round_to_15_days);
- CheckScalarUnary(op, unit, times, unit, ceil_15_weeks, &round_to_15_weeks);
- CheckScalarUnary(op, unit, times, unit, ceil_15_weeks_sunday,
- &round_to_15_weeks_sunday);
+ CheckScalarUnary(op, unit, times, unit, ceil_3_weeks, &round_to_3_weeks);
+ CheckScalarUnary(op, unit, times, unit, ceil_3_weeks_sunday, &round_to_3_weeks_sunday);
CheckScalarUnary(op, unit, times, unit, ceil_15_months, &round_to_15_months);
CheckScalarUnary(op, unit, times, unit, ceil_15_quarters, &round_to_15_quarters);
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
-TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
+TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit,
+ TestCeilTemporalMultipleSinceGreaterUnit) {
Review Comment:
For example:
```suggestion
TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit, UTC) {
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] github-actions[bot] commented on pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #13462:
URL: https://github.com/apache/arrow/pull/13462#issuecomment-1169890830
https://issues.apache.org/jira/browse/ARROW-16932
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
pitrou commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913900179
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2585,14 +2626,110 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, ceil_13_minute, &round_to_13_minutes);
CheckScalarUnary(op, unit, times, unit, ceil_15_hour, &round_to_15_hours);
CheckScalarUnary(op, unit, times, unit, ceil_15_day, &round_to_15_days);
- CheckScalarUnary(op, unit, times, unit, ceil_15_weeks, &round_to_15_weeks);
- CheckScalarUnary(op, unit, times, unit, ceil_15_weeks_sunday,
- &round_to_15_weeks_sunday);
+ CheckScalarUnary(op, unit, times, unit, ceil_3_weeks, &round_to_3_weeks);
+ CheckScalarUnary(op, unit, times, unit, ceil_3_weeks_sunday, &round_to_3_weeks_sunday);
CheckScalarUnary(op, unit, times, unit, ceil_15_months, &round_to_15_months);
CheckScalarUnary(op, unit, times, unit, ceil_15_quarters, &round_to_15_quarters);
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit,
+ TestCeilTemporalMultipleSinceGreaterUnitZoned) {
Review Comment:
For example:
```suggestion
TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit, Zoned) {
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
pitrou commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913899900
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2460,40 +2525,16 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalStrictCeil) {
CheckScalarUnary(op, unit, times, unit, ceil_13_minute, &round_to_13_minutes);
CheckScalarUnary(op, unit, times, unit, ceil_15_hour, &round_to_15_hours);
CheckScalarUnary(op, unit, times, unit, ceil_15_day, &round_to_15_days);
- CheckScalarUnary(op, unit, times, unit, ceil_15_weeks, &round_to_15_weeks);
- CheckScalarUnary(op, unit, times, unit, ceil_15_weeks_sunday,
- &round_to_15_weeks_sunday);
+ CheckScalarUnary(op, unit, times, unit, ceil_3_weeks, &round_to_3_weeks);
+ CheckScalarUnary(op, unit, times, unit, ceil_3_weeks_sunday, &round_to_3_weeks_sunday);
CheckScalarUnary(op, unit, times, unit, ceil_15_months, &round_to_15_months);
CheckScalarUnary(op, unit, times, unit, ceil_15_quarters, &round_to_15_quarters);
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
-TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
+TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit,
+ TestCeilTemporalMultipleSinceGreaterUnit) {
Review Comment:
Can make the test name shorter :-)
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
pitrou commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913901819
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2460,40 +2525,16 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalStrictCeil) {
CheckScalarUnary(op, unit, times, unit, ceil_13_minute, &round_to_13_minutes);
CheckScalarUnary(op, unit, times, unit, ceil_15_hour, &round_to_15_hours);
CheckScalarUnary(op, unit, times, unit, ceil_15_day, &round_to_15_days);
- CheckScalarUnary(op, unit, times, unit, ceil_15_weeks, &round_to_15_weeks);
- CheckScalarUnary(op, unit, times, unit, ceil_15_weeks_sunday,
- &round_to_15_weeks_sunday);
+ CheckScalarUnary(op, unit, times, unit, ceil_3_weeks, &round_to_3_weeks);
+ CheckScalarUnary(op, unit, times, unit, ceil_3_weeks_sunday, &round_to_3_weeks_sunday);
CheckScalarUnary(op, unit, times, unit, ceil_15_months, &round_to_15_months);
CheckScalarUnary(op, unit, times, unit, ceil_15_quarters, &round_to_15_quarters);
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
-TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
+TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit,
+ TestCeilTemporalMultipleSinceGreaterUnit) {
Review Comment:
Similar suggestions apply for the other test names, of course.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] rok commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
rok commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913958098
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2460,40 +2525,16 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalStrictCeil) {
CheckScalarUnary(op, unit, times, unit, ceil_13_minute, &round_to_13_minutes);
CheckScalarUnary(op, unit, times, unit, ceil_15_hour, &round_to_15_hours);
CheckScalarUnary(op, unit, times, unit, ceil_15_day, &round_to_15_days);
- CheckScalarUnary(op, unit, times, unit, ceil_15_weeks, &round_to_15_weeks);
- CheckScalarUnary(op, unit, times, unit, ceil_15_weeks_sunday,
- &round_to_15_weeks_sunday);
+ CheckScalarUnary(op, unit, times, unit, ceil_3_weeks, &round_to_3_weeks);
+ CheckScalarUnary(op, unit, times, unit, ceil_3_weeks_sunday, &round_to_3_weeks_sunday);
CheckScalarUnary(op, unit, times, unit, ceil_15_months, &round_to_15_months);
CheckScalarUnary(op, unit, times, unit, ceil_15_quarters, &round_to_15_quarters);
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
-TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
+TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit,
+ TestCeilTemporalMultipleSinceGreaterUnit) {
Review Comment:
Yes, certainly!
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] rok commented on pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
rok commented on PR #13462:
URL: https://github.com/apache/arrow/pull/13462#issuecomment-1174215964
@pitrou I moved things to fixtures and checked the data. I think this is ready for another review.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] rok commented on pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
rok commented on PR #13462:
URL: https://github.com/apache/arrow/pull/13462#issuecomment-1175231989
@pitrou I changed the names and addressed the `ceil_is_strictly_greater = true` issue.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a diff in pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
pitrou commented on code in PR #13462:
URL: https://github.com/apache/arrow/pull/13462#discussion_r913040588
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2911,6 +3032,129 @@ TEST_F(ScalarTemporalTest, TestFloorTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, floor_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestFloorTemporalMultipleSinceGreaterUnitZoned) {
+ std::string op = "floor_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_5_months =
+ RoundTemporalOptions(5, CalendarUnit::MONTH, true, true, true);
+ RoundTemporalOptions round_to_3_quarters =
+ RoundTemporalOptions(3, CalendarUnit::QUARTER, true, true, true);
+ RoundTemporalOptions round_to_15_years =
+ RoundTemporalOptions(15, CalendarUnit::YEAR, true, true, true);
+
+ // Data for tests below was generaed via lubridate with the exception
Review Comment:
```suggestion
// Data for tests below was generated via lubridate with the exception
```
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2593,6 +2593,127 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnitZoned) {
+ std::string op = "ceil_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_5_months =
+ RoundTemporalOptions(5, CalendarUnit::MONTH, true, true, true);
+ RoundTemporalOptions round_to_3_quarters =
+ RoundTemporalOptions(3, CalendarUnit::QUARTER, true, true, true);
+ RoundTemporalOptions round_to_15_years =
+ RoundTemporalOptions(15, CalendarUnit::YEAR, true, true, true);
+
+ // Data for tests below was generaed via lubridate with the exception
+ // of week data because lubridate currently does not support rounding to
+ // multiple of week.
+ const char* ceil_15_nanosecond =
+ R"(["1970-01-01 00:00:59.123456795", "2000-02-29 23:23:24.000000005",
+ "1899-01-01 00:59:20.001001015", "2033-05-18 03:33:20.000000015",
+ "2020-01-01 01:05:05.001000015", "2019-12-31 02:10:10.002000015",
+ "2019-12-30 03:15:15.003000015", "2009-12-31 04:20:20.004132015",
+ "2010-01-01 05:25:25.005321015", "2010-01-03 06:30:30.006163015",
+ "2010-01-04 07:35:35.000000015", "2006-01-01 08:40:40.000000015",
+ "2005-12-31 09:45:45.000000015", "2008-12-28 00:00:00.000000015",
+ "2008-12-29 00:00:00.000000015", "2012-01-01 01:02:03.000000015", null])";
+ const char* ceil_15_microsecond =
+ R"(["1970-01-01 00:00:59.123465", "2000-02-29 23:23:24.000005",
+ "1899-01-01 00:59:20.001015", "2033-05-18 03:33:20.000015",
+ "2020-01-01 01:05:05.001015", "2019-12-31 02:10:10.002015",
+ "2019-12-30 03:15:15.003015", "2009-12-31 04:20:20.004135",
+ "2010-01-01 05:25:25.005330", "2010-01-03 06:30:30.006165",
+ "2010-01-04 07:35:35.000015", "2006-01-01 08:40:40.000015",
+ "2005-12-31 09:45:45.000015", "2008-12-28 00:00:00.000015",
+ "2008-12-29 00:00:00.000015", "2012-01-01 01:02:03.000015", null])";
+ const char* ceil_15_millisecond =
+ R"(["1970-01-01 00:00:59.135", "2000-02-29 23:23:24.005",
+ "1899-01-01 00:59:20.015", "2033-05-18 03:33:20.015",
+ "2020-01-01 01:05:05.015", "2019-12-31 02:10:10.015",
+ "2019-12-30 03:15:15.015", "2009-12-31 04:20:20.015",
+ "2010-01-01 05:25:25.015", "2010-01-03 06:30:30.015",
+ "2010-01-04 07:35:35.015", "2006-01-01 08:40:40.015",
+ "2005-12-31 09:45:45.015", "2008-12-28 00:00:00.015",
+ "2008-12-29 00:00:00.015", "2012-01-01 01:02:03.015", null])";
+ const char* ceil_13_second = R"([
+ "1970-01-01 00:01:05", "2000-02-29 23:23:26", "1899-01-01 00:59:26", "2033-05-18 03:33:26",
+ "2020-01-01 01:05:13", "2019-12-31 02:10:13", "2019-12-30 03:15:26", "2009-12-31 04:20:26",
+ "2010-01-01 05:25:26", "2010-01-03 06:30:39", "2010-01-04 07:35:39", "2006-01-01 08:40:52",
+ "2005-12-31 09:45:52", "2008-12-28 00:00:13", "2008-12-29 00:00:13", "2012-01-01 01:02:13", null])";
+ const char* ceil_13_minute = R"([
+ "1970-01-01 00:09:00", "2000-02-29 23:35:00", "1899-01-01 01:05:00", "2033-05-18 03:43:00",
+ "2020-01-01 01:09:00", "2019-12-31 02:22:00", "2019-12-30 03:22:00", "2009-12-31 04:22:00",
+ "2010-01-01 05:35:00", "2010-01-03 06:43:00", "2010-01-04 07:43:00", "2006-01-01 08:43:00",
+ "2005-12-31 09:56:00", "2008-12-28 00:09:00", "2008-12-29 00:09:00", "2012-01-01 01:09:00", null])";
+ const char* ceil_15_hour = R"([
+ "1970-01-01 05:30:00", "2000-03-01 04:30:00", "1899-01-01 06:00:00", "2033-05-18 05:30:00",
+ "2020-01-01 04:30:00", "2019-12-31 04:30:00", "2019-12-30 04:30:00", "2009-12-31 04:30:00",
+ "2010-01-01 19:30:00", "2010-01-03 19:30:00", "2010-01-04 19:30:00", "2006-01-01 19:30:00",
+ "2005-12-31 19:30:00", "2008-12-28 04:30:00", "2008-12-29 04:30:00", "2012-01-01 04:30:00", null])";
+ const char* ceil_15_day = R"([
+ "1970-01-15 14:30:00", "2000-03-15 13:30:00", "1899-01-15 15:00:00", "2033-05-30 14:30:00",
+ "2020-01-15 13:30:00", "2020-01-14 13:30:00", "2019-12-30 13:30:00", "2010-01-14 13:30:00",
+ "2010-01-15 13:30:00", "2010-01-15 13:30:00", "2010-01-15 13:30:00", "2006-01-15 13:30:00",
+ "2006-01-14 13:30:00", "2008-12-30 13:30:00", "2008-12-30 13:30:00", "2012-01-15 13:30:00", null])";
+ const char* ceil_15_weeks = R"([
+ "1970-04-12 14:30:00", "2000-04-16 14:30:00", "1899-04-16 15:00:00", "2033-07-31 14:30:00",
+ "2020-04-12 14:30:00", "2020-04-12 14:30:00", "2020-04-12 14:30:00", "2010-04-18 14:30:00",
+ "2010-04-18 14:30:00", "2010-04-18 14:30:00", "2010-04-18 14:30:00", "2006-04-16 14:30:00",
+ "2006-04-16 14:30:00", "2009-02-22 13:30:00", "2009-04-12 14:30:00", "2012-04-15 14:30:00", null])";
+ const char* ceil_15_weeks_sunday = R"([
+ "1970-04-18 14:30:00", "2000-04-15 14:30:00", "1899-04-15 15:00:00", "2033-07-30 14:30:00",
+ "2020-04-11 14:30:00", "2020-04-11 14:30:00", "2020-04-11 14:30:00", "2010-04-17 14:30:00",
+ "2010-04-17 14:30:00", "2010-04-17 14:30:00", "2010-04-17 14:30:00", "2006-04-15 14:30:00",
+ "2006-04-15 14:30:00", "2009-04-18 14:30:00", "2009-04-18 14:30:00", "2012-04-14 14:30:00", null])";
+ const char* ceil_5_months = R"([
+ "1970-05-31 14:30:00", "2000-05-31 14:30:00", "1899-05-31 14:30:00", "2033-05-31 14:30:00",
+ "2020-05-31 14:30:00", "2020-03-31 13:30:00", "2020-03-31 13:30:00", "2010-03-31 13:30:00",
+ "2010-05-31 14:30:00", "2010-05-31 14:30:00", "2010-05-31 14:30:00", "2006-05-31 14:30:00",
+ "2006-03-31 13:30:00", "2009-03-31 13:30:00", "2009-03-31 13:30:00", "2012-05-31 14:30:00", null])";
+ const char* ceil_3_quarters = R"([
+ "1970-09-30 14:30:00", "2000-09-30 14:30:00", "1899-09-30 14:30:00", "2033-09-30 14:30:00",
+ "2020-09-30 14:30:00", "2020-06-30 14:30:00", "2020-06-30 14:30:00", "2010-06-30 14:30:00",
+ "2010-09-30 14:30:00", "2010-09-30 14:30:00", "2010-09-30 14:30:00", "2006-09-30 14:30:00",
+ "2006-06-30 14:30:00", "2009-06-30 14:30:00", "2009-06-30 14:30:00", "2012-09-30 14:30:00", null])";
+ const char* ceil_15_years = R"([
+ "1979-12-31 13:30:00", "2009-12-31 13:30:00", "1904-12-31 14:30:00", "2039-12-31 13:30:00",
+ "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2009-12-31 13:30:00",
+ "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2024-12-31 13:30:00", "2009-12-31 13:30:00",
+ "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2024-12-31 13:30:00", null])";
+
+ auto unit = timestamp(TimeUnit::NANO, "Australia/Broken_Hill");
Review Comment:
Can you comment what the concrete offsets and DST times are?
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2593,6 +2593,127 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnitZoned) {
+ std::string op = "ceil_temporal";
+ RoundTemporalOptions round_to_15_nanoseconds =
Review Comment:
Are these options repeated around? Perhaps they should be factored in a test fixture class?
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -2593,6 +2593,127 @@ TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, ceil_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestCeilTemporalMultipleSinceGreaterUnitZoned) {
+ std::string op = "ceil_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_5_months =
+ RoundTemporalOptions(5, CalendarUnit::MONTH, true, true, true);
+ RoundTemporalOptions round_to_3_quarters =
+ RoundTemporalOptions(3, CalendarUnit::QUARTER, true, true, true);
+ RoundTemporalOptions round_to_15_years =
+ RoundTemporalOptions(15, CalendarUnit::YEAR, true, true, true);
+
+ // Data for tests below was generaed via lubridate with the exception
Review Comment:
```suggestion
// Data for tests below was generated via lubridate with the exception
```
##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -3249,6 +3493,128 @@ TEST_F(ScalarTemporalTest, TestRoundTemporalMultipleSinceGreaterUnit) {
CheckScalarUnary(op, unit, times, unit, round_15_years, &round_to_15_years);
}
+TEST_F(ScalarTemporalTest, TestRoundTemporalMultipleSinceGreaterUnitZoned) {
+ 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_5_months =
+ RoundTemporalOptions(5, CalendarUnit::MONTH, true, true, true);
+ RoundTemporalOptions round_to_3_quarters =
+ RoundTemporalOptions(3, CalendarUnit::QUARTER, true, true, true);
+ RoundTemporalOptions round_to_15_years =
+ RoundTemporalOptions(15, CalendarUnit::YEAR, true, true, true);
+
+ // Data for tests below was generaed via lubridate with the exception
Review Comment:
```suggestion
// Data for tests below was generated via lubridate with the exception
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] rok commented on pull request #13462: ARROW-16932: [C++] Rounding RoundTemporalOptions.calendar_based_origin doesn't correctly offset non-UTC results
Posted by GitBox <gi...@apache.org>.
rok commented on PR #13462:
URL: https://github.com/apache/arrow/pull/13462#issuecomment-1175236937
> Cool, thanks for the persistence :-)
Thank you for the great reviews! :)
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org