westonpace commented on code in PR #35356:
URL: https://github.com/apache/arrow/pull/35356#discussion_r1261984772


##########
python/pyarrow/array.pxi:
##########
@@ -2542,8 +2542,14 @@ cdef class DictionaryArray(Array):
     def dictionary_decode(self):
         """
         Decodes the DictionaryArray to an Array.
+
+        See :func:`pyarrow.compute.dictionary_decode` for usage.
+
+        Returns
+        -------
+        dictionary_decode : Array
         """
-        return self.dictionary.take(self.indices)
+        return _pc().dictionary_decode(self)

Review Comment:
   Did the old approach work?  I wonder if this will introduce any subtle 
differences?  Is there a reason we need to change this method?



##########
python/pyarrow/array.pxi:
##########
@@ -2542,8 +2542,14 @@ cdef class DictionaryArray(Array):
     def dictionary_decode(self):
         """
         Decodes the DictionaryArray to an Array.
+
+        See :func:`pyarrow.compute.dictionary_decode` for usage.
+
+        Returns
+        -------
+        dictionary_decode : Array

Review Comment:
   ```suggestion
           decoded_array : Array
   ```



##########
python/pyarrow/tests/test_compute.py:
##########
@@ -1755,6 +1755,20 @@ def test_logical():
     assert pc.invert(a) == pa.array([False, True, True, None])
 
 
+def test_dictionary_decode():
+    array = pa.array(["a", "a", "b", "c", "b"])
+    dictionary_array = array.dictionary_encode()
+    dictionary_array_decode = dictionary_array.dictionary_decode()
+
+    assert array != dictionary_array
+
+    assert array == dictionary_array_decode
+    assert array == pc.dictionary_decode(dictionary_array)
+
+    with pytest.raises(TypeError):
+        pc.dictionary_decode(array)

Review Comment:
   Shouldn't this be ok now?



##########
python/pyarrow/compute.py:
##########
@@ -333,6 +333,68 @@ def _make_global_functions():
 _make_global_functions()
 
 
+def dictionary_decode(arr, memory_pool=None):

Review Comment:
   Many of the compute functions are automatically described from the function 
registry (through some kind of python metaclass magic).  I don't really know 
how this works.  Maybe we still need to define this method since it is a meta 
function?  But I think it might work even if you don't define this method.  Can 
you try removing this method and see if the code still works?
   
   CC @jorisvandenbossche or @bkietz who might know more details.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to