You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "AlenkaF (via GitHub)" <gi...@apache.org> on 2023/04/20 16:18:55 UTC

[GitHub] [arrow] AlenkaF commented on a diff in pull request #34658: GH-21761: [Python] accept pyarrow values / scalars in constructor functions ?

AlenkaF commented on code in PR #34658:
URL: https://github.com/apache/arrow/pull/34658#discussion_r1172823110


##########
python/pyarrow/array.pxi:
##########
@@ -318,11 +318,29 @@ def array(object obj, type=None, mask=None, size=None, from_pandas=None,
             if pandas_api.have_pandas:
                 values, type = pandas_api.compat.get_datetimetz_type(
                     values, obj.dtype, type)
-            result = _ndarray_to_array(values, mask, type, c_from_pandas, safe,
-                                       pool)
+            try:
+                result = _ndarray_to_array(values, mask, type, c_from_pandas, safe,
+                                           pool)
+            except ArrowInvalid as err:
+                if "Scalar" in str(err):

Review Comment:
   Oh yeah, it's very hacky! =)
   I have tried multiple ways of catching the specific `ArrowInvalid` error as others are expected here also, but all of them have some issue. Can try to remember them all and list them, but Joris advised me to go into the Python C++ code and use `ConvertToSequenceAndInferSize` so this will be changed. I should convert this PR into a draft to make this clear.
   
   Thank you for reviewing!



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