You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by GitBox <gi...@apache.org> on 2022/12/14 22:27:31 UTC
[GitHub] [arrow] pbmi opened a new issue, #14955: ArrowNotImplementedError: Unifying differing dictionaries
pbmi opened a new issue, #14955:
URL: https://github.com/apache/arrow/issues/14955
### Describe the bug, including details regarding any error messages, version, and platform.
I received the above error when trying to run group_by() with a key column defined as dictionary<values=string, indices=int32, ordered=0>
When I changed the key column to string(), group_by() ran successfully.
I am therefore guessing that key columns of datatype dictionary are currently not supported by group_by().
Is gorup_by() support for dictionary key columns planned?
Current setup is :
Windows 11
Python 3.10
pyarrow 10.0.1
### Component(s)
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: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++][Python] Unifying differing dictionaries in Arrow compute [arrow]
Posted by "AlenkaF (via GitHub)" <gi...@apache.org>.
AlenkaF commented on issue #14955:
URL: https://github.com/apache/arrow/issues/14955#issuecomment-4854696959
PS: the other TODO is in the [cpp/src/arrow/compute/row/row_encoder_internal.cc](https://github.com/apache/arrow/blob/7ebe6e9a62f9f22abe0b5c79013c40649bc77a5c/cpp/src/arrow/compute/row/row_encoder_internal.cc#L224).
--
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: [I] [Python] ArrowNotImplementedError: Unifying differing dictionaries [arrow]
Posted by "AlenkaF (via GitHub)" <gi...@apache.org>.
AlenkaF commented on issue #14955:
URL: https://github.com/apache/arrow/issues/14955#issuecomment-4854677086
This issue still exists, see most possible [todo from the codebase](https://github.com/apache/arrow/blob/7ebe6e9a62f9f22abe0b5c79013c40649bc77a5c/cpp/src/arrow/compute/row/grouper.cc#L696). It can be tackled, in case there is a need and will to do so, or closed as **Not Planned** (which I would do).
The error happens in a multi-chunk table since a single-chunk dictionary array works fine. The suggested workaround is actually a sensible step to take (unifying the dictionaries):
```python
In [1]: import pyarrow as pa
...: chunk1 = pa.DictionaryArray.from_arrays(
...: pa.array([0, 1, 0], type=pa.int32()),
...: pa.array(["a", "b"])
...: )
...: chunk2 = pa.DictionaryArray.from_arrays(
...: pa.array([0, 1, 2], type=pa.int32()),
...: pa.array(["b", "c", "d"]) # different dictionary!
...: )
...:
...: tbl = pa.table({
...: "k": pa.chunked_array([chunk1, chunk2]),
...: "v": pa.chunked_array([[1, 2, 3], [4, 5, 6]])
...: })
In [2]: tbl
Out[2]:
pyarrow.Table
k: dictionary<values=string, indices=int32, ordered=0>
v: int64
----
k: [ -- dictionary:
["a","b"] -- indices:
[0,1,0], -- dictionary:
["b","c","d"] -- indices:
[0,1,2]]
v: [[1,2,3],[4,5,6]]
In [3]: tbl.group_by("k").aggregate([("v", "sum")])
...
ArrowNotImplementedError: Unifying differing dictionaries
...
In [4]: tbl.unify_dictionaries()
Out[4]:
pyarrow.Table
k: dictionary<values=string, indices=int32, ordered=0>
v: int64
----
k: [ -- dictionary:
["a","b","c","d"] -- indices:
[0,1,0], -- dictionary:
["a","b","c","d"] -- indices:
[1,2,3]]
v: [[1,2,3],[4,5,6]]
In [5]: tbl.unify_dictionaries().group_by("k").aggregate([("v", "sum")])
Out[5]:
pyarrow.Table
k: dictionary<values=string, indices=int32, ordered=0>
v_sum: int64
----
k: [ -- dictionary:
["a","b","c","d"] -- indices:
[1,2,3,0]]
v_sum: [[6,5,6,4]]
```
--
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: [I] [C++][Python] Unifying differing dictionaries in Arrow compute [arrow]
Posted by "thisisnic (via GitHub) via github" <gi...@arrow.apache.org>.
thisisnic commented on issue #14955:
URL: https://github.com/apache/arrow/issues/14955#issuecomment-6739841114
Had AI take a look and make an R reproducer, and I'm gonna relabel it as "enhancement" as it'd be useful to fix this on the R side at least. AI analysis below!
--------------------------------------------
--
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
[GitHub] [arrow] coady commented on issue #14955: [Python] ArrowNotImplementedError: Unifying differing dictionaries
Posted by "coady (via GitHub)" <gi...@apache.org>.
coady commented on issue #14955:
URL: https://github.com/apache/arrow/issues/14955#issuecomment-1637161836
Instead of decoding the dictionary array(s), they can be explicitly unified before grouping: `{pa.Table,pa.ChunkedArray}.unify_dictionaries`.
--
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
[GitHub] [arrow] westonpace commented on issue #14955: [Python] ArrowNotImplementedError: Unifying differing dictionaries
Posted by GitBox <gi...@apache.org>.
westonpace commented on issue #14955:
URL: https://github.com/apache/arrow/issues/14955#issuecomment-1353820807
> Is group_by() support for dictionary key columns planned?
It is an open source project so we don't really have concrete plans. People work on the features that are important to them. That being said, I'm not aware of any existing PRs to handle this and I don't know anyone that has announced they intend to work on this.
However, this would be a good addition (it would be nice if dictionaries could move through all exec plan nodes / kernel functions, even if not using the most optimal implementation) and I would be happy to review a PR if someone can create one.
--
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