You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "goalzz85 (via GitHub)" <gi...@apache.org> on 2024/10/21 12:16:10 UTC

Re: [I] How to load a table with bucket partition [iceberg-python]

goalzz85 commented on issue #548:
URL: https://github.com/apache/iceberg-python/issues/548#issuecomment-2426506481

   ```python
   table = catalog.load_table(("default", "mq_log10"))
   
   scan = table.scan()
   file_scan_tasks = scan.plan_files()
   
   partition_num = 20
   new_file_scan_tasks = []
   for task in file_scan_tasks:
       if task.file.partition[0] == partition_num:
           new_file_scan_tasks.append(task)
   
   # reference:
   # https://github.com/apache/iceberg-python/blob/pyiceberg-0.7.1/pyiceberg/table/__init__.py#L2014
   # @deprecated(
   #    deprecated_in="0.8.0",
   #    removed_in="0.9.0",
   #    help_message="project_table is deprecated. Use ArrowScan.to_table instead.",
   # )
   from pyiceberg.io.pyarrow import project_table
   
   pa_data_table = project_table(new_file_scan_tasks, scan.table_metadata, scan.io, scan.row_filter, scan.projection(), case_sensitive=scan.case_sensitive, limit=scan.limit)
   ```
   
   I use this code to load a table with a bucketed partition, which may be useful for you. You should note that the project_table function will be removed in version 0.9.0, but you can refer to the new implementation and rewrite this code.


-- 
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@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org