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



##########
File path: r/src/compute.cpp
##########
@@ -521,6 +521,20 @@ std::shared_ptr<arrow::compute::FunctionOptions> 
make_compute_options(
     return out;
   }
 
+  if (func_name == "round_temporal" || func_name == "floor_temporal" ||
+      func_name == "ceil_temporal") {
+    using Options = arrow::compute::RoundTemporalOptions;
+    auto out = std::make_shared<Options>(Options::Defaults());
+    SEXP unit = options["unit"];
+    if (!Rf_isNull(unit)) {
+      out->unit = cpp11::as_cpp<enum arrow::compute::CalendarUnit>(unit);
+    }
+    if (!Rf_isNull(options["multiple"])) {
+      out->multiple = cpp11::as_cpp<int64_t>(options["multiple"]);
+    }
+    return out;
+  }

Review comment:
       I think you need to set the defaults somewhat like this now:
   
   ```suggestion
     if (func_name == "round_temporal" || func_name == "floor_temporal" ||
         func_name == "ceil_temporal") {
       using Options = arrow::compute::RoundTemporalOptions;
       
       int64_t multiple = 1;
       enum arrow::compute::CalendarUnit unit = 
arrow::compute::CalendarUnit::DAY;
       bool week_starts_monday = true;
       bool change_on_boundary = true;
       bool calendar_based_origin = true;
   
       if (!Rf_isNull(options["multiple"])) {
         multiple = cpp11::as_cpp<int64_t>(options["multiple"]);
       }
       if (!Rf_isNull(options["unit"])) {
         unit = cpp11::as_cpp<enum 
arrow::compute::CalendarUnit>(options["unit"]);
       }
       if (!Rf_isNull(options["week_starts_monday"])) {
         week_starts_monday = 
cpp11::as_cpp<int64_t>(options["week_starts_monday"]);
       }
       if (!Rf_isNull(options["change_on_boundary"])) {
         change_on_boundary = 
cpp11::as_cpp<int64_t>(options["change_on_boundary"]);
       }
       if (!Rf_isNull(options["calendar_based_origin"])) {
         calendar_based_origin = 
cpp11::as_cpp<int64_t>(options["calendar_based_origin"]);
       }
       return std::make_shared<Options>(multiple, unit, week_starts_monday, 
change_on_boundary, calendar_based_origin);
     }
   ```
   
   Also please note I've not tried compiling this so there might be errors.




-- 
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