Fokko commented on code in PR #4340:
URL: https://github.com/apache/iceberg-python/pull/4340#discussion_r4699901398


##########
pyiceberg/transforms.py:
##########
@@ -132,12 +132,15 @@ def _cast_if_needed(arr: "ArrayLike") -> "ArrayLike":
             else:
                 return arr
 
+        def _decode_if_dictionary(arr: "ArrayLike") -> "ArrayLike":
+            return arr.dictionary_decode() if pa.types.is_dictionary(arr.type) 
else arr
+
         if isinstance(array, pa.Array):
-            return _cast_if_needed(transform_func(array, *args))
+            return 
_cast_if_needed(transform_func(_decode_if_dictionary(array), *args))

Review Comment:
   We don't always have to decode the dictionary, for example, for an identity 
or void transform, this isn't needed. How about doing this as part of 
`pyarrow_transform`?



##########
tests/test_transforms.py:
##########
@@ -1701,6 +1701,24 @@ def test_bucket_pyarrow_transforms(
     assert expected == transform.pyarrow_transform(source_type)(input_arr)
 
 
+def test_pyarrow_transform_decodes_dictionary_arrays() -> None:
+    transform: Transform[Any, Any] = BucketTransform(num_buckets=8)

Review Comment:
   Can we parameterize the test to go over all the transforms?



##########
tests/catalog/test_catalog_behaviors.py:
##########
@@ -338,6 +338,24 @@ def test_write_pyarrow_schema(catalog: Catalog, 
test_table_identifier: Identifie
     table.append(pyarrow_table)
 
 
+def test_write_dictionary_encoded_column_with_bucket_partition(catalog: 
Catalog) -> None:

Review Comment:
   I don't think this is catalog related, let's remove this test



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to