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/03/22 07:18:48 UTC

[GitHub] [arrow] jorisvandenbossche commented on a change in pull request #12660: ARROW-15965: [Python] Add Scalar constructor of RoundToMultipleOptions to Python

jorisvandenbossche commented on a change in pull request #12660:
URL: https://github.com/apache/arrow/pull/12660#discussion_r831836585



##########
File path: python/pyarrow/_compute.pyx
##########
@@ -898,10 +898,16 @@ class RoundTemporalOptions(_RoundTemporalOptions):
 
 cdef class _RoundToMultipleOptions(FunctionOptions):
     def _set_options(self, multiple, round_mode):
-        self.wrapped.reset(
-            new CRoundToMultipleOptions(multiple,
-                                        unwrap_round_mode(round_mode))
-        )
+        if isinstance(multiple, Scalar):
+            self.wrapped.reset(
+                new CRoundToMultipleOptions(pyarrow_unwrap_scalar(multiple),
+                                            unwrap_round_mode(round_mode))
+            )
+        else:
+            self.wrapped.reset(
+                new CRoundToMultipleOptions(<double> multiple,
+                                            unwrap_round_mode(round_mode))
+            )

Review comment:
       It might not be strictly needed to test that a string errors (this already happens on master as well), but you needed to add additional code to enable a new feature: being able to pass a pyarrow scalar. So to ensure this actually works and keeps working, this requires a python test (note that being able to pass a pyarrow scalar is not something that other option classes actually support in general).




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