You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "pitrou (via GitHub)" <gi...@apache.org> on 2024/02/29 15:56:04 UTC

[PR] GH-40153: [Python] Avoid using np.take in Array.to_numpy() [arrow]

pitrou opened a new pull request, #40295:
URL: https://github.com/apache/arrow/pull/40295

   ### Rationale for this change
   
   `Array.to_numpy` calls `np.take` to linearize dictionary arrays. This fails on 32-bit Numpy builds because we give Numpy 64-bit indices and Numpy would like to downcast them.
   
   ### What changes are included in this PR?
   
   Avoid calling `np.take`, instead using our own dictionary decoding routine.
   
   ### Are these changes tested?
   
   Yes. A test failure is fixed on 32-bit.
   
   ### Are there any user-facing changes?
   
   No.


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


Re: [PR] GH-40153: [Python] Avoid using np.take in Array.to_numpy() [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #40295:
URL: https://github.com/apache/arrow/pull/40295#discussion_r1507877520


##########
python/pyarrow/src/arrow/python/arrow_to_pandas.cc:
##########
@@ -2515,6 +2515,8 @@ Status ConvertChunkedArrayToPandas(const PandasOptions& options,
                                    std::shared_ptr<ChunkedArray> arr, PyObject* py_ref,
                                    PyObject** out) {
   if (options.decode_dictionaries && arr->type()->id() == Type::DICTIONARY) {
+    // XXX we should return an error as below if options.zero_copy_only
+    // is true, but that would break compatibility with existing tests.

Review Comment:
   Yes.



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


Re: [PR] GH-40153: [Python] Avoid using np.take in Array.to_numpy() [arrow]

Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #40295:
URL: https://github.com/apache/arrow/pull/40295#issuecomment-1972596427

   After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit 5c4869d453717d8946549cac408998759c5084d9.
   
   There was 1 benchmark result indicating a performance regression:
   
   - Commit Run on `ursa-i9-9960x` at [2024-03-01 00:48:47Z](https://conbench.ursa.dev/compare/runs/73528f49088b4137a1fadc278a5bc726...a640f4bc07fc4d4b97c7b19bd8aba524/)
     - [`tpch` (R) with engine=arrow, format=native, language=R, memory_map=False, query_id=TPCH-17, scale_factor=1](https://conbench.ursa.dev/compare/benchmarks/065e11d7f35a70d5800053214c7a7f75...065e13e5228f793180001f030a696477)
   
   The [full Conbench report](https://github.com/apache/arrow/runs/22159271055) has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them.


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


Re: [PR] GH-40153: [Python] Avoid using np.take in Array.to_numpy() [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou merged PR #40295:
URL: https://github.com/apache/arrow/pull/40295


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


Re: [PR] GH-40153: [Python] Avoid using np.take in Array.to_numpy() [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on PR #40295:
URL: https://github.com/apache/arrow/pull/40295#issuecomment-1971441828

   @github-actions crossbow submit -g python


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


Re: [PR] GH-40153: [Python] Avoid using np.take in Array.to_numpy() [arrow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #40295:
URL: https://github.com/apache/arrow/pull/40295#issuecomment-1971446615

   Revision: 7fc1ec7ada20506bb39fd21f37063c61289cff93
   
   Submitted crossbow builds: [ursacomputing/crossbow @ actions-a31e58e0d0](https://github.com/ursacomputing/crossbow/branches/all?query=actions-a31e58e0d0)
   
   |Task|Status|
   |----|------|
   |test-conda-python-3.10|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.10)](https://github.com/ursacomputing/crossbow/actions/runs/8098880288/job/22133344284)|
   |test-conda-python-3.10-cython2|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.10-cython2)](https://github.com/ursacomputing/crossbow/actions/runs/8098880002/job/22133343093)|
   |test-conda-python-3.10-hdfs-2.9.2|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.10-hdfs-2.9.2)](https://github.com/ursacomputing/crossbow/actions/runs/8098881061/job/22133346749)|
   |test-conda-python-3.10-hdfs-3.2.1|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.10-hdfs-3.2.1)](https://github.com/ursacomputing/crossbow/actions/runs/8098880719/job/22133345215)|
   |test-conda-python-3.10-pandas-latest|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.10-pandas-latest)](https://github.com/ursacomputing/crossbow/actions/runs/8098880249/job/22133343662)|
   |test-conda-python-3.10-pandas-nightly|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.10-pandas-nightly)](https://github.com/ursacomputing/crossbow/actions/runs/8098880149/job/22133343452)|
   |test-conda-python-3.10-spark-v3.5.0|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.10-spark-v3.5.0)](https://github.com/ursacomputing/crossbow/actions/runs/8098880397/job/22133344502)|
   |test-conda-python-3.10-substrait|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.10-substrait)](https://github.com/ursacomputing/crossbow/actions/runs/8098880843/job/22133345820)|
   |test-conda-python-3.11|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.11)](https://github.com/ursacomputing/crossbow/actions/runs/8098880575/job/22133344991)|
   |test-conda-python-3.11-dask-latest|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.11-dask-latest)](https://github.com/ursacomputing/crossbow/actions/runs/8098880307/job/22133344087)|
   |test-conda-python-3.11-dask-upstream_devel|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.11-dask-upstream_devel)](https://github.com/ursacomputing/crossbow/actions/runs/8098880912/job/22133346599)|
   |test-conda-python-3.11-hypothesis|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.11-hypothesis)](https://github.com/ursacomputing/crossbow/actions/runs/8098880588/job/22133345309)|
   |test-conda-python-3.11-pandas-upstream_devel|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.11-pandas-upstream_devel)](https://github.com/ursacomputing/crossbow/actions/runs/8098880369/job/22133344296)|
   |test-conda-python-3.11-spark-master|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.11-spark-master)](https://github.com/ursacomputing/crossbow/actions/runs/8098880349/job/22133344245)|
   |test-conda-python-3.12|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.12)](https://github.com/ursacomputing/crossbow/actions/runs/8098880216/job/22133343635)|
   |test-conda-python-3.8|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.8)](https://github.com/ursacomputing/crossbow/actions/runs/8098880809/job/22133345696)|
   |test-conda-python-3.8-pandas-1.0|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.8-pandas-1.0)](https://github.com/ursacomputing/crossbow/actions/runs/8098880302/job/22133344432)|
   |test-conda-python-3.8-spark-v3.5.0|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.8-spark-v3.5.0)](https://github.com/ursacomputing/crossbow/actions/runs/8098880909/job/22133346410)|
   |test-conda-python-3.9|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.9)](https://github.com/ursacomputing/crossbow/actions/runs/8098880870/job/22133346140)|
   |test-conda-python-3.9-pandas-latest|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-conda-python-3.9-pandas-latest)](https://github.com/ursacomputing/crossbow/actions/runs/8098880867/job/22133346131)|
   |test-cuda-python|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-cuda-python)](https://github.com/ursacomputing/crossbow/actions/runs/8098880254/job/22133343797)|
   |test-debian-11-python-3-amd64|[![Azure](https://dev.azure.com/ursacomputing/crossbow/_apis/build/status/ursacomputing.crossbow?branchName=actions-a31e58e0d0-azure-test-debian-11-python-3-amd64)](https://github.com/ursacomputing/crossbow/runs/22133349569)|
   |test-debian-11-python-3-i386|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-debian-11-python-3-i386)](https://github.com/ursacomputing/crossbow/actions/runs/8098880741/job/22133345403)|
   |test-fedora-39-python-3|[![Azure](https://dev.azure.com/ursacomputing/crossbow/_apis/build/status/ursacomputing.crossbow?branchName=actions-a31e58e0d0-azure-test-fedora-39-python-3)](https://github.com/ursacomputing/crossbow/runs/22133350584)|
   |test-ubuntu-20.04-python-3|[![Azure](https://dev.azure.com/ursacomputing/crossbow/_apis/build/status/ursacomputing.crossbow?branchName=actions-a31e58e0d0-azure-test-ubuntu-20.04-python-3)](https://github.com/ursacomputing/crossbow/runs/22133348619)|
   |test-ubuntu-22.04-python-3|[![GitHub Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-a31e58e0d0-github-test-ubuntu-22.04-python-3)](https://github.com/ursacomputing/crossbow/actions/runs/8098880795/job/22133345650)|


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


Re: [PR] GH-40153: [Python] Avoid using np.take in Array.to_numpy() [arrow]

Posted by "jorisvandenbossche (via GitHub)" <gi...@apache.org>.
jorisvandenbossche commented on code in PR #40295:
URL: https://github.com/apache/arrow/pull/40295#discussion_r1507848831


##########
python/pyarrow/src/arrow/python/arrow_to_pandas.cc:
##########
@@ -2515,6 +2515,8 @@ Status ConvertChunkedArrayToPandas(const PandasOptions& options,
                                    std::shared_ptr<ChunkedArray> arr, PyObject* py_ref,
                                    PyObject** out) {
   if (options.decode_dictionaries && arr->type()->id() == Type::DICTIONARY) {
+    // XXX we should return an error as below if options.zero_copy_only
+    // is true, but that would break compatibility with existing tests.

Review Comment:
   At the moment we essentially just ignore the `zero_copy_only` keyword in case of a DictionaryArray?



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