romainfrancois commented on a change in pull request #11850:
URL: https://github.com/apache/arrow/pull/11850#discussion_r766732853



##########
File path: r/src/r_to_arrow.cpp
##########
@@ -580,33 +583,37 @@ int64_t get_TimeUnit_multiplier(TimeUnit::type unit) {
   }
 }
 
+Result<int> get_difftime_unit_multiplier(SEXP x) {
+  std::string unit(CHAR(STRING_ELT(Rf_getAttrib(x, symbols::units), 0)));
+  if (unit == "secs") {
+    return 1;
+  } else if (unit == "mins") {
+    return 60;
+  } else if (unit == "hours") {
+    return 3600;
+  } else if (unit == "days") {
+    return 86400;
+  } else if (unit == "weeks") {
+    return 604800;
+  } else {
+    return Status::Invalid("unknown difftime unit");
+  }
+}
+
 template <typename T>
 class RPrimitiveConverter<T, enable_if_t<is_time_type<T>::value>>
     : public PrimitiveConverter<T, RConverter> {
  public:
   Status Extend(SEXP x, int64_t size, int64_t offset = 0) override {
     RETURN_NOT_OK(this->Reserve(size - offset));
     auto rtype = GetVectorType(x);
-    if (rtype != TIME) {
+    // This probably also not accept duration
+    if (rtype != TIME && rtype != DURATION) {

Review comment:
       ```suggestion
       if (rtype != TIME) {
   ```
   
   I believe `DURATION` (i.e. <difftime>) should not be dealt with here. 




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