Anurag-S1ngh opened a new pull request, #4340:
URL: https://github.com/apache/iceberg-python/pull/4340

   # Rationale for this change
   
   Appending a dictionary-encoded Arrow table to a table partitioned by 
`bucket`, `truncate`, `year`, `month`, `day` or `hour` raised:
   
   ```
   ValueError: FeatureUnsupported => Unsupported data type for bucket 
transform: Dictionary(Int32, Utf8)
   ```
   
   The partition transforms run on Arrow arrays through 
`_pyiceberg_transform_wrapper`, which forwarded the array as-is. The Arrow 
kernels behind the transforms have no implementation for dictionary types, so 
any dictionary-encoded column used in a partition transform failed even though 
Iceberg has no dictionary type and reads such a column as its value type.
   
   The wrapper now decodes dictionary arrays with `dictionary_decode()` before 
calling the transform, per chunk for chunked arrays. The result matches what 
the same values produce without dictionary encoding, so partitions, and 
therefore partition pruning, stay the same.
   
   # Are these changes tested?
   
   Yes.
   
   - 
`tests/test_transforms.py::test_pyarrow_transform_decodes_dictionary_arrays` 
covers both `pa.Array` and `pa.ChunkedArray` and asserts the dictionary-encoded 
input gives the same buckets as the plain input, including a null.
   - 
`tests/catalog/test_catalog_behaviors.py::test_write_dictionary_encoded_column_with_bucket_partition`
 appends a dictionary-encoded table to a bucket-partitioned table, checks the 
rows read back and that both partitions were created. It runs against the 
memory, sql, and sql_without_rowcount catalogs.
   
   Both fail on main and pass with the change.
   
   Full unit suite: `4573 passed, 5 skipped`. `prek run -a` passes.
   
   # Are there any user-facing changes?
   
   Yes. Appending dictionary-encoded columns to a table with a partition 
transform now works instead of raising `FeatureUnsupported`.
   
   Closes #3633
   


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