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/05/18 07:41:06 UTC

[GitHub] [arrow] jorisvandenbossche commented on a diff in pull request #13109: ARROW-15365: [Python] Expose full cast options in the pyarrow.compute.cast function

jorisvandenbossche commented on code in PR #13109:
URL: https://github.com/apache/arrow/pull/13109#discussion_r875567732


##########
python/pyarrow/compute.py:
##########
@@ -369,10 +371,14 @@ def cast(arr, target_type, safe=True):
     """
     if target_type is None:
         raise ValueError("Cast target type must not be None")
-    if safe:
-        options = CastOptions.safe(target_type)
-    else:
-        options = CastOptions.unsafe(target_type)
+    if (safe is not None) and (options is not None):
+        raise ValueError(
+            "Must past only a value for 'safe' or only a value for 'options'")
+    if options is None:
+        if safe:

Review Comment:
   We will need some handling here to interpret `safe=None` as `safe=True` (now it will be interpreted as False, which explains the test failures)



##########
python/pyarrow/array.pxi:
##########
@@ -905,14 +905,16 @@ cdef class Array(_PandasConvertible):
         ----------
         target_type : DataType
             Type to cast array to.
-        safe : boolean, default True
+        safe : boolean, default None

Review Comment:
   Although we changed it in the signature, I would keep it here as "True", because that is still the actual default behaviour if you don't specify neither of the params.



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