[
https://issues.apache.org/jira/browse/ARROW-2017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16340226#comment-16340226
]
ASF GitHub Bot commented on ARROW-2017:
---------------------------------------
xhochy closed pull request #1504: ARROW-2017: [Python] Use unsigned PyLong API
for uint64 values over int64 range
URL: https://github.com/apache/arrow/pull/1504
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/cpp/src/arrow/python/builtin_convert.cc
b/cpp/src/arrow/python/builtin_convert.cc
index cd88d557d..0879b3f98 100644
--- a/cpp/src/arrow/python/builtin_convert.cc
+++ b/cpp/src/arrow/python/builtin_convert.cc
@@ -511,7 +511,7 @@ class UInt32Converter : public
TypedConverterVisitor<UInt32Builder, UInt32Conver
class UInt64Converter : public TypedConverterVisitor<UInt64Builder,
UInt64Converter> {
public:
Status AppendItem(const OwnedRef& item) {
- const auto val = static_cast<int64_t>(PyLong_AsLongLong(item.obj()));
+ const auto val =
static_cast<int64_t>(PyLong_AsUnsignedLongLong(item.obj()));
RETURN_IF_PYERROR();
return typed_builder_->Append(val);
}
diff --git a/python/pyarrow/tests/test_array.py
b/python/pyarrow/tests/test_array.py
index fa38c9257..2d991119f 100644
--- a/python/pyarrow/tests/test_array.py
+++ b/python/pyarrow/tests/test_array.py
@@ -485,6 +485,12 @@ def test_logical_type(type, expected):
assert get_logical_type(type) == expected
+def test_array_uint64_from_py_over_range():
+ arr = pa.array([2 ** 63], type=pa.uint64())
+ expected = pa.array(np.array([2 ** 63], dtype='u8'))
+ assert arr.equals(expected)
+
+
def test_array_conversions_no_sentinel_values():
arr = np.array([1, 2, 3, 4], dtype='int8')
refcount = sys.getrefcount(arr)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Array initialization with large (>2**31-1) uint64 values fails
> ---------------------------------------------------------------
>
> Key: ARROW-2017
> URL: https://issues.apache.org/jira/browse/ARROW-2017
> Project: Apache Arrow
> Issue Type: Bug
> Components: Python
> Affects Versions: 0.8.0
> Environment: python 3.6, 3.5, 2.7, on OSX and Linux
> Reporter: Ian Roddis
> Assignee: Wes McKinney
> Priority: Major
> Labels: pull-request-available
> Fix For: 0.9.0
>
>
> Trying to create pyarrow arrays with large values causes a 'too big to
> convert' error:
> Python 3.5.1 (default, Jun 6 2016, 14:30:01)
> Type "copyright", "credits" or "license" for more information.
> IPython 5.1.0 -- An enhanced Interactive Python.
> ? -> Introduction and overview of IPython's features.
> %quickref -> Quick reference.
> help -> Python's own help system.
> object? -> Details about 'object', use 'object??' for extra details.
> In [1]: import pyarrow as pa
> In [2]: pa.array([2**63-1], type=pa.uint64())
> Out[2]:
> <pyarrow.lib.UInt64Array object at 0x1050e73b8>
> [
> 9223372036854775807
> ]
> In [3]: pa.array([2**63], type=pa.uint64())
> ---------------------------------------------------------------------------
> ArrowException Traceback (most recent call last)
> <ipython-input-3-0d103b16c512> in <module>()
> ----> 1 pa.array([2**63], type=pa.uint64())
> /Users/roddis/.pyenv/versions/3.5.1/envs/g3.5.1/lib/python3.5/site-packages/pyarrow/array.pxi
> in pyarrow.lib.array
> (/Users/travis/build/BryanCutler/arrow-dist/arrow/python/build/temp.macosx-10.6-intel-3.5/lib.cxx:29283)()
> /Users/roddis/.pyenv/versions/3.5.1/envs/g3.5.1/lib/python3.5/site-packages/pyarrow/array.pxi
> in pyarrow.lib._sequence_to_array
> (/Users/travis/build/BryanCutler/arrow-dist/arrow/python/build/temp.macosx-10.6-intel-3.5/lib.cxx:27945)()
> /Users/roddis/.pyenv/versions/3.5.1/envs/g3.5.1/lib/python3.5/site-packages/pyarrow/error.pxi
> in pyarrow.lib.check_status
> (/Users/travis/build/BryanCutler/arrow-dist/arrow/python/build/temp.macosx-10.6-intel-3.5/lib.cxx:9068)()
> ArrowException: Unknown error: int too big to conver
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)