rok commented on a change in pull request #11818:
URL: https://github.com/apache/arrow/pull/11818#discussion_r775567886



##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -1848,6 +1849,64 @@ def test_assume_timezone():
     result.equals(pa.array(expected))
 
 
+units = (
+    "nanosecond",
+    "microsecond",
+    "millisecond",
+    "second",
+    "minute",
+    "hour",
+    "day",
+)
+unit_shorthand = {
+    "nanosecond": "ns",
+    "microsecond": "us",
+    "millisecond": "L",
+    "second": "s",
+    "minute": "min",
+    "hour": "H",
+    "day": "D"
+}
+
+
+# TODO: We should test on windows once ARROW-13168 is resolved.
+@pytest.mark.pandas
+@pytest.mark.skipif(sys.platform == 'win32',
+                    reason="Timezone database is not available on Windows yet")
+@pytest.mark.parametrize('unit', units)
+def test_round_temporal(unit):
+    # timezones = ["UTC", "US/Central", "Asia/Kolkata",
+    #              "Etc/GMT-4", "Etc/GMT+4", "Australia/Broken_Hill"]
+    # timezones = ["UTC", "Etc/GMT+4"]

Review comment:
       They are commented out to please the CI. Still working on the C++ logic.

##########
File path: cpp/src/arrow/compute/kernels/scalar_temporal_test.cc
##########
@@ -1324,6 +1361,555 @@ TEST_F(ScalarTemporalTest, TestTemporalDifferenceZoned) 
{
   }
 }
 
+TEST_F(ScalarTemporalTest, TestCeilTemporal) {
+  std::string op = "ceil_temporal";
+  const char* ceil_1_nanosecond =
+      R"(["1970-01-01 00:00:59.123456789", "2000-02-29 23:23:23.999999999",
+          "1899-01-01 00:59:20.001001001", "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* ceil_1_microsecond =
+      R"(["1970-01-01 00:00:59.123457", "2000-02-29 23:23:24.000000",
+          "1899-01-01 00:59:20.001002", "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.004132",
+          "2010-01-01 05:25:25.005321", "2010-01-03 06:30:30.006163",
+          "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* ceil_1_millisecond =
+      R"(["1970-01-01 00:00:59.124", "2000-02-29 23:23:24.000",
+          "1899-01-01 00:59:20.002", "2033-05-18 03:33:20.000",
+          "2020-01-01 01:05:05.001", "2019-12-31 02:10:10.002",
+          "2019-12-30 03:15:15.003", "2009-12-31 04:20:20.005",
+          "2010-01-01 05:25:25.006", "2010-01-03 06:30:30.007",
+          "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* ceil_1_second =
+      R"(["1970-01-01 00:01:00", "2000-02-29 23:23:24", "1899-01-01 00:59:21",
+          "2033-05-18 03:33:20", "2020-01-01 01:05:06", "2019-12-31 02:10:11",
+          "2019-12-30 03:15:16", "2009-12-31 04:20:21", "2010-01-01 05:25:26",
+          "2010-01-03 06:30:31", "2010-01-04 07:35:35", "2006-01-01 08:40:40",
+          "2005-12-31 09:45:45", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:02:03", null])";
+  const char* ceil_1_minute =
+      R"(["1970-01-01 00:01:00", "2000-02-29 23:24:00", "1899-01-01 01:00:00",
+          "2033-05-18 03:34:00", "2020-01-01 01:06:00", "2019-12-31 02:11:00",
+          "2019-12-30 03:16:00", "2009-12-31 04:21:00", "2010-01-01 05:26:00",
+          "2010-01-03 06:31:00", "2010-01-04 07:36:00", "2006-01-01 08:41:00",
+          "2005-12-31 09:46:00", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:03:00", null])";
+  const char* ceil_1_hour =
+      R"(["1970-01-01 01:00:00", "2000-03-01 00:00:00", "1899-01-01 01:00:00",
+          "2033-05-18 04:00:00", "2020-01-01 02:00:00", "2019-12-31 03:00:00",
+          "2019-12-30 04:00:00", "2009-12-31 05:00:00", "2010-01-01 06:00:00",
+          "2010-01-03 07:00:00", "2010-01-04 08:00:00", "2006-01-01 09:00:00",
+          "2005-12-31 10:00:00", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 02:00:00", null])";
+  const char* ceil_1_day =
+      R"(["1970-01-02", "2000-03-01", "1899-01-02", "2033-05-19", "2020-01-02",
+          "2020-01-01", "2019-12-31", "2010-01-01", "2010-01-02", "2010-01-04",
+          "2010-01-05", "2006-01-02", "2006-01-01", "2008-12-28", "2008-12-29",
+          "2012-01-02", null])";
+  const char* ceil_1_weeks =
+      R"(["1970-01-08", "2000-03-02", "1899-01-05", "2033-05-19", "2020-01-02",
+          "2020-01-02", "2020-01-02", "2010-01-07", "2010-01-07", "2010-01-07",
+          "2010-01-07", "2006-01-05", "2006-01-05", "2009-01-01", "2009-01-01",
+          "2012-01-05",  null])";
+  const char* ceil_1_months =
+      R"(["1970-02-01", "2000-03-01", "1899-02-01", "2033-06-01", "2020-02-01",
+          "2020-01-01", "2020-01-01", "2010-01-01", "2010-02-01", "2010-02-01",
+          "2010-02-01", "2006-02-01", "2006-01-01", "2009-01-01", "2009-01-01",
+          "2012-02-01", null])";
+  const char* ceil_1_quarters =
+      R"(["1970-04-01", "2000-04-01", "1899-04-01", "2033-07-01", "2020-04-01",
+          "2020-01-01", "2020-01-01", "2010-01-01", "2010-04-01", "2010-04-01",
+          "2010-04-01", "2006-04-01", "2006-01-01", "2009-01-01", "2009-01-01",
+          "2012-04-01", null])";
+  const char* ceil_1_years =
+      R"(["1971-01-01", "2001-01-01", "1900-01-01", "2034-01-01", "2021-01-01",
+          "2020-01-01", "2020-01-01", "2010-01-01", "2011-01-01", "2011-01-01",
+          "2011-01-01", "2007-01-01", "2006-01-01", "2009-01-01", "2009-01-01",
+          "2013-01-01", null])";
+  const char* ceil_15_nanosecond =
+      R"(["1970-01-01 00:00:59.123456790", "2000-02-29 23:23:24.000000000",
+          "1899-01-01 00:59:20.001001005", "2033-05-18 03:33:20.000000010",
+          "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.006163005",
+          "2010-01-04 07:35:35.000000010", "2006-01-01 08:40:40.000000005",
+          "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* ceil_15_microsecond =
+      R"(["1970-01-01 00:00:59.123460", "2000-02-29 23:23:24.000000",
+          "1899-01-01 00:59:20.001015", "2033-05-18 03:33:20.000010",
+          "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.005330", "2010-01-03 06:30:30.006165",
+          "2010-01-04 07:35:35.000010", "2006-01-01 08:40:40.000005",
+          "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* ceil_15_millisecond =
+      R"(["1970-01-01 00:00:59.130", "2000-02-29 23:23:24.000",
+          "1899-01-01 00:59:20.010", "2033-05-18 03:33:20.010",
+          "2020-01-01 01:05:05.010", "2019-12-31 02:10:10.005",
+          "2019-12-30 03:15:15.015", "2009-12-31 04:20:20.010",
+          "2010-01-01 05:25:25.020", "2010-01-03 06:30:30.015",
+          "2010-01-04 07:35:35.010", "2006-01-01 08:40:40.005",
+          "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* ceil_15_second =
+      R"(["1970-01-01 00:01:00", "2000-02-29 23:23:30", "1899-01-01 00:59:30",
+          "2033-05-18 03:33:30", "2020-01-01 01:05:15", "2019-12-31 02:10:15",
+          "2019-12-30 03:15:30", "2009-12-31 04:20:30", "2010-01-01 05:25:30",
+          "2010-01-03 06:30:45", "2010-01-04 07:35:45", "2006-01-01 08:40:45",
+          "2005-12-31 09:45:45", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:02:15", null])";
+  const char* ceil_15_minute =
+      R"(["1970-01-01 00:15:00", "2000-02-29 23:30:00", "1899-01-01 01:00:00",
+          "2033-05-18 03:45:00", "2020-01-01 01:15:00", "2019-12-31 02:15:00",
+          "2019-12-30 03:30:00", "2009-12-31 04:30:00", "2010-01-01 05:30:00",
+          "2010-01-03 06:45:00", "2010-01-04 07:45:00", "2006-01-01 08:45:00",
+          "2005-12-31 10:00:00", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:15:00", null])";
+  const char* ceil_15_hour =
+      R"(["1970-01-01 15:00:00", "2000-03-01 12:00:00", "1899-01-01 03:00:00",
+          "2033-05-18 18:00:00", "2020-01-01 12:00:00", "2019-12-31 06:00:00",
+          "2019-12-30 15:00:00", "2009-12-31 09:00:00", "2010-01-01 15:00:00",
+          "2010-01-03 12:00:00", "2010-01-04 18:00:00", "2006-01-01 09:00:00",
+          "2005-12-31 18:00:00", "2008-12-28 06:00:00", "2008-12-29 12:00:00",
+          "2012-01-01 15:00:00", null])";
+  const char* ceil_15_day =
+      R"(["1970-01-16", "2000-03-09", "1899-01-13", "2033-05-30", "2020-01-09",
+          "2020-01-09", "2020-01-09", "2010-01-01", "2010-01-16", "2010-01-16",
+          "2010-01-16", "2006-01-07", "2006-01-07", "2009-01-06", "2009-01-06",
+          "2012-01-06", null])";
+  const char* ceil_15_weeks =
+      R"(["1970-04-16", "2000-03-09", "1899-04-13", "2033-07-14", "2020-01-09",
+          "2020-01-09", "2020-01-09", "2010-04-01", "2010-04-01", "2010-04-01",
+          "2010-04-01", "2006-03-23", "2006-03-23", "2009-02-05", "2009-02-05",
+          "2012-04-05", null])";  // TODO: verify
+  const char* ceil_15_months =
+      R"(["1971-04-01", "2001-04-01", "1900-01-01", "2033-10-01", "2021-04-01",
+          "2020-01-01", "2020-01-01", "2010-01-01", "2011-04-01", "2011-04-01",
+          "2011-04-01", "2006-04-01", "2006-04-01", "2010-01-01", "2010-01-01",
+          "2012-07-01", null])";
+  const char* ceil_15_quarters =
+      R"(["1973-10-01", "2003-10-01", "1902-07-01", "2033-10-01", "2022-07-01",
+          "2022-07-01", "2022-07-01", "2011-04-01", "2011-04-01", "2011-04-01",
+          "2011-04-01", "2007-07-01", "2007-07-01", "2011-04-01", "2011-04-01",
+          "2015-01-01", null])";
+  const char* ceil_15_years =
+      R"(["1980-01-01", "2010-01-01", "1905-01-01", "2040-01-01", "2025-01-01",
+          "2025-01-01", "2025-01-01", "2010-01-01", "2025-01-01", "2025-01-01",
+          "2025-01-01", "2010-01-01", "2010-01-01", "2010-01-01", "2010-01-01",
+          "2025-01-01", null])";
+
+  auto unit = timestamp(TimeUnit::NANO, "UTC");
+  CheckScalarUnary(op, unit, times, unit, ceil_1_nanosecond, 
&round_to_1_nanoseconds);
+  CheckScalarUnary(op, unit, times, unit, ceil_1_microsecond, 
&round_to_1_microseconds);
+  CheckScalarUnary(op, unit, times, unit, ceil_1_millisecond, 
&round_to_1_milliseconds);
+  CheckScalarUnary(op, unit, times, unit, ceil_1_second, &round_to_1_seconds);
+  CheckScalarUnary(op, unit, times, unit, ceil_1_minute, &round_to_1_minutes);
+  CheckScalarUnary(op, unit, times, unit, ceil_1_hour, &round_to_1_hours);
+  CheckScalarUnary(op, unit, times, unit, ceil_1_day, &round_to_1_days);
+  CheckScalarUnary(op, unit, times, unit, ceil_1_weeks, &round_to_1_weeks);
+  CheckScalarUnary(op, unit, times, unit, ceil_1_months, &round_to_1_months);
+  CheckScalarUnary(op, unit, times, unit, ceil_1_quarters, 
&round_to_1_quarters);
+  CheckScalarUnary(op, unit, times, unit, ceil_1_years, &round_to_1_years);
+
+  CheckScalarUnary(op, unit, times, unit, ceil_15_nanosecond, 
&round_to_15_nanoseconds);
+  CheckScalarUnary(op, unit, times, unit, ceil_15_microsecond, 
&round_to_15_microseconds);
+  CheckScalarUnary(op, unit, times, unit, ceil_15_millisecond, 
&round_to_15_milliseconds);
+  CheckScalarUnary(op, unit, times, unit, ceil_15_second, 
&round_to_15_seconds);
+  CheckScalarUnary(op, unit, times, unit, ceil_15_minute, 
&round_to_15_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_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);
+
+  RoundTemporalOptions round_to_2_hours = RoundTemporalOptions(2, 
CalendarUnit::HOUR);
+  const char* times_a = R"(["2021-12-23 12:17", null])";
+  const char* times_b = R"(["2021-12-23 13:00", null])";
+  auto unit_brussels = timestamp(TimeUnit::NANO, "Europe/Brussels");
+  CheckScalarUnary(op, unit_brussels, times_a, unit_brussels, times_b, 
&round_to_2_hours);
+}
+
+TEST_F(ScalarTemporalTest, TestFloorTemporal) {
+  std::string op = "floor_temporal";
+  const char* floor_1_nanosecond =
+      R"(["1970-01-01 00:00:59.123456789", "2000-02-29 23:23:23.999999999",
+          "1899-01-01 00:59:20.001001001", "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_1_microsecond =
+      R"(["1970-01-01 00:00:59.123456", "2000-02-29 23:23:23.999999",
+          "1899-01-01 00:59:20.001001", "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.004132",
+          "2010-01-01 05:25:25.005321", "2010-01-03 06:30:30.006163",
+          "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_1_millisecond =
+      R"(["1970-01-01 00:00:59.123", "2000-02-29 23:23:23.999",
+          "1899-01-01 00:59:20.001", "2033-05-18 03:33:20.000",
+          "2020-01-01 01:05:05.001", "2019-12-31 02:10:10.002",
+          "2019-12-30 03:15:15.003", "2009-12-31 04:20:20.004",
+          "2010-01-01 05:25:25.005", "2010-01-03 06:30:30.006",
+          "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_1_second =
+      R"(["1970-01-01 00:00:59", "2000-02-29 23:23:23", "1899-01-01 00:59:20",
+          "2033-05-18 03:33:20", "2020-01-01 01:05:05", "2019-12-31 02:10:10",
+          "2019-12-30 03:15:15", "2009-12-31 04:20:20", "2010-01-01 05:25:25",
+          "2010-01-03 06:30:30", "2010-01-04 07:35:35", "2006-01-01 08:40:40",
+          "2005-12-31 09:45:45", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:02:03", null])";
+  const char* floor_1_minute =
+      R"(["1970-01-01 00:00:00", "2000-02-29 23:23:00", "1899-01-01 00:59:00",
+          "2033-05-18 03:33:00", "2020-01-01 01:05:00", "2019-12-31 02:10:00",
+          "2019-12-30 03:15:00", "2009-12-31 04:20:00", "2010-01-01 05:25:00",
+          "2010-01-03 06:30:00", "2010-01-04 07:35:00", "2006-01-01 08:40:00",
+          "2005-12-31 09:45:00", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:02:00", null])";
+  const char* floor_1_hour =
+      R"(["1970-01-01 00:00:00", "2000-02-29 23:00:00", "1899-01-01 00:00:00",
+          "2033-05-18 03:00:00", "2020-01-01 01:00:00", "2019-12-31 02:00:00",
+          "2019-12-30 03:00:00", "2009-12-31 04:00:00", "2010-01-01 05:00:00",
+          "2010-01-03 06:00:00", "2010-01-04 07:00:00", "2006-01-01 08:00:00",
+          "2005-12-31 09:00:00", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:00:00", null])";
+  const char* floor_1_day =
+      R"(["1970-01-01", "2000-02-29", "1899-01-01", "2033-05-18", "2020-01-01",
+          "2019-12-31", "2019-12-30", "2009-12-31", "2010-01-01", "2010-01-03",
+          "2010-01-04", "2006-01-01", "2005-12-31", "2008-12-28", "2008-12-29",
+          "2012-01-01", null])";
+  const char* floor_1_weeks =
+      R"(["1970-01-01", "2000-02-24", "1898-12-29", "2033-05-12", "2019-12-26",
+            "2019-12-26", "2019-12-26", "2009-12-31", "2009-12-31", 
"2009-12-31",
+            "2009-12-31", "2005-12-29", "2005-12-29", "2008-12-25", 
"2008-12-25",
+            "2011-12-29", null])";
+  const char* floor_1_months =
+      R"(["1970-01-01", "2000-02-01", "1899-01-01", "2033-05-01", "2020-01-01",
+          "2019-12-01", "2019-12-01", "2009-12-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", "2006-01-01", "2005-12-01", "2008-12-01", "2008-12-01",
+          "2012-01-01", null])";
+  const char* floor_1_quarters =
+      R"(["1970-01-01", "2000-01-01", "1899-01-01", "2033-04-01", "2020-01-01",
+          "2019-10-01", "2019-10-01", "2009-10-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", "2006-01-01", "2005-10-01", "2008-10-01", "2008-10-01",
+          "2012-01-01", null])";
+  const char* floor_1_years =
+      R"(["1970-01-01", "2000-01-01", "1899-01-01", "2033-01-01", "2020-01-01",
+          "2019-01-01", "2019-01-01", "2009-01-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", "2006-01-01", "2005-01-01", "2008-01-01", "2008-01-01",
+          "2012-01-01", null])";
+
+  const char* floor_15_nanosecond =
+      R"(["1970-01-01 00:00:59.123456775", "2000-02-29 23:23:23.999999985",
+          "1899-01-01 00:59:20.001000990", "2033-05-18 03:33:19.999999995",
+          "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.006162990",
+          "2010-01-04 07:35:34.999999995", "2006-01-01 08:40:39.999999990",
+          "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.123445", "2000-02-29 23:23:23.999985",
+          "1899-01-01 00:59:20.001000", "2033-05-18 03:33:19.999995",
+          "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:34.999995", "2006-01-01 08:40:39.999990",
+          "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.115", "2000-02-29 23:23:23.985",
+          "1899-01-01 00:59:19.995", "2033-05-18 03:33:19.995",
+          "2020-01-01 01:05:04.995", "2019-12-31 02:10:09.990",
+          "2019-12-30 03:15:15.000", "2009-12-31 04:20:19.995",
+          "2010-01-01 05:25:25.005", "2010-01-03 06:30:30.000",
+          "2010-01-04 07:35:34.995", "2006-01-01 08:40:39.990",
+          "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_15_second =
+      R"(["1970-01-01 00:00:45", "2000-02-29 23:23:15", "1899-01-01 00:59:15",
+          "2033-05-18 03:33:15", "2020-01-01 01:05:00", "2019-12-31 02:10:00",
+          "2019-12-30 03:15:15", "2009-12-31 04:20:15", "2010-01-01 05:25:15",
+          "2010-01-03 06:30:30", "2010-01-04 07:35:30", "2006-01-01 08:40:30",
+          "2005-12-31 09:45:45", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:02:00", null])";
+  const char* floor_15_minute =
+      R"(["1970-01-01 00:00:00", "2000-02-29 23:15:00", "1899-01-01 00:45:00",
+          "2033-05-18 03:30:00", "2020-01-01 01:00:00", "2019-12-31 02:00:00",
+          "2019-12-30 03:15:00", "2009-12-31 04:15:00", "2010-01-01 05:15:00",
+          "2010-01-03 06:30:00", "2010-01-04 07:30:00", "2006-01-01 08:30:00",
+          "2005-12-31 09:45:00", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:00:00", null])";
+  const char* floor_15_hour =
+      R"(["1970-01-01 00:00:00", "2000-02-29 21:00:00", "1898-12-31 12:00:00",
+          "2033-05-18 03:00:00", "2019-12-31 21:00:00", "2019-12-30 15:00:00",
+          "2019-12-30 00:00:00", "2009-12-30 18:00:00", "2010-01-01 00:00:00",
+          "2010-01-02 21:00:00", "2010-01-04 03:00:00", "2005-12-31 18:00:00",
+          "2005-12-31 03:00:00", "2008-12-27 15:00:00", "2008-12-28 21:00:00",
+          "2012-01-01 00:00:00", null])";
+  const char* floor_15_day =
+      R"(["1970-01-01", "2000-02-23", "1898-12-29", "2033-05-15", "2019-12-25",
+          "2019-12-25", "2019-12-25", "2009-12-17", "2010-01-01", "2010-01-01",
+          "2010-01-01", "2005-12-23", "2005-12-23", "2008-12-22", "2008-12-22",
+          "2011-12-22", null])";
+  const char* floor_15_weeks =
+      R"(["1970-01-01", "1999-11-25", "1898-12-29", "2033-03-31", "2019-09-26",
+          "2019-09-26", "2019-09-26", "2009-12-17", "2009-12-17", "2009-12-17",
+          "2009-12-17", "2005-12-08", "2005-12-08", "2008-10-23", "2008-10-23",
+          "2011-12-22", null])";  // TODO: verify
+  const char* floor_15_months =
+      R"(["1970-01-01", "2000-01-01", "1898-10-01", "2032-07-01", "2020-01-01",
+          "2018-10-01", "2018-10-01", "2008-10-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", "2005-01-01", "2005-01-01", "2008-10-01", "2008-10-01",
+          "2011-04-01", null])";
+  const char* floor_15_quarters =
+      R"(["1970-01-01", "2000-01-01", "1898-10-01", "2030-01-01", "2018-10-01",
+          "2018-10-01", "2018-10-01", "2007-07-01", "2007-07-01", "2007-07-01",
+          "2007-07-01", "2003-10-01", "2003-10-01", "2007-07-01", "2007-07-01",
+          "2011-04-01", null])";
+  const char* floor_15_years =
+      R"(["1965-01-01", "1995-01-01", "1890-01-01", "2025-01-01", "2010-01-01",
+          "2010-01-01", "2010-01-01", "1995-01-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", "1995-01-01", "1995-01-01", "1995-01-01", "1995-01-01",
+          "2010-01-01", null])";
+
+  auto unit = timestamp(TimeUnit::NANO, "UTC");
+  CheckScalarUnary(op, unit, times, unit, floor_1_nanosecond, 
&round_to_1_nanoseconds);
+  CheckScalarUnary(op, unit, times, unit, floor_1_microsecond, 
&round_to_1_microseconds);
+  CheckScalarUnary(op, unit, times, unit, floor_1_millisecond, 
&round_to_1_milliseconds);
+  CheckScalarUnary(op, unit, times, unit, floor_1_second, &round_to_1_seconds);
+  CheckScalarUnary(op, unit, times, unit, floor_1_minute, &round_to_1_minutes);
+  CheckScalarUnary(op, unit, times, unit, floor_1_hour, &round_to_1_hours);
+  CheckScalarUnary(op, unit, times, unit, floor_1_day, &round_to_1_days);
+  CheckScalarUnary(op, unit, times, unit, floor_1_weeks, &round_to_1_weeks);
+  CheckScalarUnary(op, unit, times, unit, floor_1_months, &round_to_1_months);
+  CheckScalarUnary(op, unit, times, unit, floor_1_quarters, 
&round_to_1_quarters);
+  CheckScalarUnary(op, unit, times, unit, floor_1_years, &round_to_1_years);
+
+  CheckScalarUnary(op, unit, times, unit, floor_15_nanosecond, 
&round_to_15_nanoseconds);
+  CheckScalarUnary(op, unit, times, unit, floor_15_microsecond,
+                   &round_to_15_microseconds);
+  CheckScalarUnary(op, unit, times, unit, floor_15_millisecond,
+                   &round_to_15_milliseconds);
+  CheckScalarUnary(op, unit, times, unit, floor_15_second, 
&round_to_15_seconds);
+  CheckScalarUnary(op, unit, times, unit, floor_15_minute, 
&round_to_15_minutes);
+  CheckScalarUnary(op, unit, times, unit, floor_15_hour, &round_to_15_hours);
+  CheckScalarUnary(op, unit, times, unit, floor_15_day, &round_to_15_days);
+  CheckScalarUnary(op, unit, times, unit, floor_15_weeks, &round_to_15_weeks);
+  CheckScalarUnary(op, unit, times, unit, floor_15_months, 
&round_to_15_months);
+  CheckScalarUnary(op, unit, times, unit, floor_15_quarters, 
&round_to_15_quarters);
+  CheckScalarUnary(op, unit, times, unit, floor_15_years, &round_to_15_years);
+
+  RoundTemporalOptions round_to_2_hours = RoundTemporalOptions(2, 
CalendarUnit::HOUR);
+  const char* times_a = R"(["2021-12-23 12:17", null])";
+  const char* times_b = R"(["2021-12-23 13:00", null])";
+  auto unit_brussels = timestamp(TimeUnit::NANO, "Europe/Brussels");
+  CheckScalarUnary(op, unit_brussels, times_a, unit_brussels, times_b, 
&round_to_2_hours);
+}
+
+TEST_F(ScalarTemporalTest, TestRoundTemporal) {
+  std::string op = "round_temporal";
+  const char* round_1_nanoseconds =
+      R"(["1970-01-01 00:00:59.123456789", "2000-02-29 23:23:23.999999999",
+          "1899-01-01 00:59:20.001001001", "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_1_microseconds =
+      R"(["1970-01-01 00:00:59.123457", "2000-02-29 23:23:24.000000",
+          "1899-01-01 00:59:20.001001", "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.004132",
+          "2010-01-01 05:25:25.005321", "2010-01-03 06:30:30.006163",
+          "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_1_milliseconds =
+      R"(["1970-01-01 00:00:59.123", "2000-02-29 23:23:24.000",
+          "1899-01-01 00:59:20.001", "2033-05-18 03:33:20.000",
+          "2020-01-01 01:05:05.001", "2019-12-31 02:10:10.002",
+          "2019-12-30 03:15:15.003", "2009-12-31 04:20:20.004",
+          "2010-01-01 05:25:25.005", "2010-01-03 06:30:30.006",
+          "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_1_seconds =
+      R"(["1970-01-01 00:00:59", "2000-02-29 23:23:24", "1899-01-01 00:59:20",
+          "2033-05-18 03:33:20", "2020-01-01 01:05:05", "2019-12-31 02:10:10",
+          "2019-12-30 03:15:15", "2009-12-31 04:20:20", "2010-01-01 05:25:25",
+          "2010-01-03 06:30:30", "2010-01-04 07:35:35", "2006-01-01 08:40:40",
+          "2005-12-31 09:45:45", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:02:03", null])";
+  const char* round_1_minutes =
+      R"(["1970-01-01 00:01:00", "2000-02-29 23:23:00", "1899-01-01 00:59:00",
+          "2033-05-18 03:33:00", "2020-01-01 01:05:00", "2019-12-31 02:10:00",
+          "2019-12-30 03:15:00", "2009-12-31 04:20:00", "2010-01-01 05:25:00",
+          "2010-01-03 06:31:00", "2010-01-04 07:36:00", "2006-01-01 08:41:00",
+          "2005-12-31 09:46:00", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:02:00", null])";
+  const char* round_1_hours =
+      R"(["1970-01-01 00:00:00", "2000-02-29 23:00:00", "1899-01-01 01:00:00",
+          "2033-05-18 04:00:00", "2020-01-01 01:00:00", "2019-12-31 02:00:00",
+          "2019-12-30 03:00:00", "2009-12-31 04:00:00", "2010-01-01 05:00:00",
+          "2010-01-03 07:00:00", "2010-01-04 08:00:00", "2006-01-01 09:00:00",
+          "2005-12-31 10:00:00", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:00:00", null])";
+  const char* round_1_days =
+      R"(["1970-01-01", "2000-03-01", "1899-01-01", "2033-05-18", "2020-01-01",
+          "2019-12-31", "2019-12-30", "2009-12-31", "2010-01-01", "2010-01-03",
+          "2010-01-04", "2006-01-01", "2005-12-31", "2008-12-28", "2008-12-29",
+          "2012-01-01", null])";
+  const char* round_1_weeks =
+      R"(["1970-01-01", "2000-03-02", "1898-12-29", "2033-05-19", "2020-01-02",
+          "2020-01-02", "2020-01-02", "2009-12-31", "2009-12-31", "2009-12-31",
+          "2010-01-07", "2005-12-29", "2005-12-29", "2008-12-25", "2009-01-01",
+          "2011-12-29", null])";
+  const char* round_1_months =
+      R"(["1970-01-01", "2000-03-01", "1899-01-01", "2033-06-01", "2020-01-01",
+          "2020-01-01", "2020-01-01", "2010-01-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", "2006-01-01", "2006-01-01", "2009-01-01", "2009-01-01",
+           "2012-01-01", null])";
+  const char* round_1_quarters =
+      R"(["1970-01-01", "2000-04-01", "1899-01-01", "2033-07-01", "2020-01-01",
+          "2020-01-01", "2020-01-01", "2010-01-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", "2006-01-01", "2006-01-01", "2009-01-01", "2009-01-01",
+          "2012-01-01", null])";
+  const char* round_1_years =
+      R"(["1970-01-01", "2000-01-01", "1899-01-01", "2033-01-01", "2020-01-01",
+          "2020-01-01", "2020-01-01", "2010-01-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", "2006-01-01", "2006-01-01", "2009-01-01", "2009-01-01",
+          "2012-01-01", null])";
+
+  const char* round_15_nanoseconds =
+      R"(["1970-01-01 00:00:59.123456790", "2000-02-29 23:23:24.000000000",
+          "1899-01-01 00:59:20.001001005", "2033-05-18 03:33:19.999999995",
+          "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.006163005",
+          "2010-01-04 07:35:34.999999995", "2006-01-01 08:40:40.000000005",
+          "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_microseconds =
+      R"(["1970-01-01 00:00:59.123460", "2000-02-29 23:23:24.000000",
+          "1899-01-01 00:59:20.001000", "2033-05-18 03:33:19.999995",
+          "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:34.999995", "2006-01-01 08:40:40.000005",
+          "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_milliseconds =
+      R"(["1970-01-01 00:00:59.130", "2000-02-29 23:23:24.000",
+          "1899-01-01 00:59:19.995", "2033-05-18 03:33:19.995",
+          "2020-01-01 01:05:04.995", "2019-12-31 02:10:10.005",
+          "2019-12-30 03:15:15.000", "2009-12-31 04:20:20.010",
+          "2010-01-01 05:25:25.005", "2010-01-03 06:30:30.000",
+          "2010-01-04 07:35:34.995", "2006-01-01 08:40:40.005",
+          "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_15_seconds =
+      R"(["1970-01-01 00:01:00", "2000-02-29 23:23:30", "1899-01-01 00:59:15",
+          "2033-05-18 03:33:15", "2020-01-01 01:05:00", "2019-12-31 02:10:15",
+          "2019-12-30 03:15:15", "2009-12-31 04:20:15", "2010-01-01 05:25:30",
+          "2010-01-03 06:30:30", "2010-01-04 07:35:30", "2006-01-01 08:40:45",
+          "2005-12-31 09:45:45", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:02:00", null])";
+  const char* round_15_minutes =
+      R"(["1970-01-01 00:00:00", "2000-02-29 23:30:00", "1899-01-01 01:00:00",
+          "2033-05-18 03:30:00", "2020-01-01 01:00:00", "2019-12-31 02:15:00",
+          "2019-12-30 03:15:00", "2009-12-31 04:15:00", "2010-01-01 05:30:00",
+          "2010-01-03 06:30:00", "2010-01-04 07:30:00", "2006-01-01 08:45:00",
+          "2005-12-31 09:45:00", "2008-12-28 00:00:00", "2008-12-29 00:00:00",
+          "2012-01-01 01:00:00", null])";
+  const char* round_15_hours =
+      R"(["1970-01-01 00:00:00", "2000-02-29 21:00:00", "1899-01-01 03:00:00",
+          "2033-05-18 03:00:00", "2019-12-31 21:00:00", "2019-12-31 06:00:00",
+          "2019-12-30 00:00:00", "2009-12-31 09:00:00", "2010-01-01 00:00:00",
+          "2010-01-03 12:00:00", "2010-01-04 03:00:00", "2006-01-01 09:00:00",
+          "2005-12-31 03:00:00", "2008-12-28 06:00:00", "2008-12-28 21:00:00",
+          "2012-01-01 00:00:00", null])";
+  const char* round_15_days =
+      R"(["1970-01-01", "2000-02-23", "1898-12-29", "2033-05-15", "2019-12-25",
+          "2019-12-25", "2019-12-25", "2010-01-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", "2006-01-07", "2006-01-07", "2008-12-22", "2008-12-22",
+          "2012-01-06", null])";
+  const char* round_15_weeks =
+      R"(["1970-01-01", "2000-03-09", "1898-12-29", "2033-03-31", "2020-01-09",
+          "2020-01-09", "2020-01-09", "2009-12-17", "2009-12-17", "2009-12-17",
+          "2009-12-17", "2005-12-08", "2005-12-08", "2009-02-05", "2009-02-05",
+          "2011-12-22", null])";  // TODO: verify
+  const char* round_15_months =
+      R"(["1970-01-01", "2000-01-01", "1898-10-01", "2033-10-01", "2020-01-01",
+          "2020-01-01", "2020-01-01", "2010-01-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", "2006-04-01", "2006-04-01", "2008-10-01", "2008-10-01",
+          "2012-07-01", null])";
+  const char* round_15_quarters =
+      R"(["1970-01-01", "2000-01-01", "1898-10-01", "2033-10-01", "2018-10-01",
+          "2018-10-01", "2018-10-01", "2011-04-01", "2011-04-01", "2011-04-01",
+          "2011-04-01", "2007-07-01", "2007-07-01", "2007-07-01", "2007-07-01",
+          "2011-04-01", null])";
+  const char* round_15_years =
+      R"(["1965-01-01", "1995-01-01", "1905-01-01", "2040-01-01", "2025-01-01",
+          "2025-01-01", "2025-01-01", "2010-01-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", "2010-01-01", "2010-01-01", "2010-01-01", "2010-01-01",
+          "2010-01-01", null])";
+
+  auto unit = timestamp(TimeUnit::NANO, "UTC");
+  CheckScalarUnary(op, unit, times, unit, round_1_nanoseconds, 
&round_to_1_nanoseconds);
+  CheckScalarUnary(op, unit, times, unit, round_1_microseconds, 
&round_to_1_microseconds);
+  CheckScalarUnary(op, unit, times, unit, round_1_milliseconds, 
&round_to_1_milliseconds);
+  CheckScalarUnary(op, unit, times, unit, round_1_seconds, 
&round_to_1_seconds);
+  CheckScalarUnary(op, unit, times, unit, round_1_minutes, 
&round_to_1_minutes);
+  CheckScalarUnary(op, unit, times, unit, round_1_hours, &round_to_1_hours);
+  CheckScalarUnary(op, unit, times, unit, round_1_days, &round_to_1_days);
+  CheckScalarUnary(op, unit, times, unit, round_1_weeks, &round_to_1_weeks);
+  CheckScalarUnary(op, unit, times, unit, round_1_months, &round_to_1_months);
+  CheckScalarUnary(op, unit, times, unit, round_1_quarters, 
&round_to_1_quarters);
+  CheckScalarUnary(op, unit, times, unit, round_1_years, &round_to_1_years);
+
+  CheckScalarUnary(op, unit, times, unit, round_15_nanoseconds, 
&round_to_15_nanoseconds);
+  CheckScalarUnary(op, unit, times, unit, round_15_microseconds,
+                   &round_to_15_microseconds);
+  CheckScalarUnary(op, unit, times, unit, round_15_milliseconds,
+                   &round_to_15_milliseconds);
+  CheckScalarUnary(op, unit, times, unit, round_15_seconds, 
&round_to_15_seconds);
+  CheckScalarUnary(op, unit, times, unit, round_15_minutes, 
&round_to_15_minutes);
+  CheckScalarUnary(op, unit, times, unit, round_15_hours, &round_to_15_hours);
+  CheckScalarUnary(op, unit, times, unit, round_15_days, &round_to_15_days);
+  CheckScalarUnary(op, unit, times, unit, round_15_weeks, &round_to_15_weeks);
+  CheckScalarUnary(op, unit, times, unit, round_15_months, 
&round_to_15_months);
+  CheckScalarUnary(op, unit, times, unit, round_15_quarters, 
&round_to_15_quarters);
+  CheckScalarUnary(op, unit, times, unit, round_15_years, &round_to_15_years);
+
+  RoundTemporalOptions round_to_2_hours = RoundTemporalOptions(2, 
CalendarUnit::HOUR);

Review comment:
       I think the whole bottom of the file is already and it might not show in 
the diff.




-- 
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-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to