snigdhachoppac commented on code in PR #50675:
URL: https://github.com/apache/arrow/pull/50675#discussion_r3663574640


##########
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc:
##########
@@ -3779,6 +3779,86 @@ TEST_F(ScalarTemporalTest, 
TestCeilFloorRoundTemporalDate) {
   CheckScalarUnary("ceil_temporal", arr_ns, arr_ns, &round_to_2_hours);
 }
 
+TEST_F(ScalarTemporalTest, TestCeilFloorRoundTemporalDuration) {
+  auto check_unit = [&](TimeUnit::type time_unit, CalendarUnit calendar_unit) {
+    RoundTemporalOptions round_to_2_units(2, calendar_unit);
+    auto values = ArrayFromJSON(duration(time_unit), "[0, 1, 2, 3, -1, -2, -3, 
null]");
+
+    CheckScalarUnary("ceil_temporal", values,
+                     ArrayFromJSON(duration(time_unit), "[0, 2, 2, 4, 0, -2, 
-2, null]"),
+                     &round_to_2_units);
+    CheckScalarUnary("floor_temporal", values,
+                     ArrayFromJSON(duration(time_unit), "[0, 0, 2, 2, -2, -2, 
-4, null]"),
+                     &round_to_2_units);
+    CheckScalarUnary("round_temporal", values,
+                     ArrayFromJSON(duration(time_unit), "[0, 2, 2, 4, 0, -2, 
-2, null]"),
+                     &round_to_2_units);
+  };
+
+  check_unit(TimeUnit::SECOND, CalendarUnit::SECOND);
+  check_unit(TimeUnit::MILLI, CalendarUnit::MILLISECOND);
+  check_unit(TimeUnit::MICRO, CalendarUnit::MICROSECOND);
+  check_unit(TimeUnit::NANO, CalendarUnit::NANOSECOND);
+
+  // A day is treated as a physical 24-hour unit for duration values.
+  RoundTemporalOptions round_to_day(1, CalendarUnit::DAY);
+  auto day_values = ArrayFromJSON(duration(TimeUnit::SECOND),
+                                  "[0, 43200, 86399, 86400, -1, -43200, 
null]");
+
+  CheckScalarUnary(
+      "ceil_temporal", day_values,
+      ArrayFromJSON(duration(TimeUnit::SECOND), "[0, 86400, 86400, 86400, 0, 
0, null]"),

Review Comment:
   I manually re-derived the expected values using fixed-duration boundaries, 
including negative values and halfway cases. I also added a pandas integration 
test that independently compares Arrow’s results against pandas for 
nanoseconds, microseconds, milliseconds, seconds, minutes, hours, days, and 
weeks. All 8 parameterized integration cases and the full 55-test C++ temporal 
suite pass locally.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to