You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "wjones127 (via GitHub)" <gi...@apache.org> on 2023/05/05 21:53:52 UTC

[GitHub] [arrow] wjones127 commented on pull request #35453: GH-35331: [Python] Expose Parquet sorting metadata

wjones127 commented on PR #35453:
URL: https://github.com/apache/arrow/pull/35453#issuecomment-1536823450

   Intended usage:
   
   ```python
   import pyarrow as pa
   import pyarrow.parquet as pq
   import pyarrow.compute as pc
   
   tab = pa.table({
       'a': pa.array([1, 3, 2, 2]),
       'b': pa.array(['a', 'b', 'c', 'd'])
   })
   
   sort_keys = [('a', 'ascending'), ('b', 'descending')]
   sorted_tab = tab.sort_by(sort_keys)
   
   pq.write_table(tab, 'data.parquet', sorting_columns=sort_keys)
   
   metadata = pq.read_metadata('data.parquet')
   metadata.row_group(0).sorting_columns
   
   pq_file = pq.ParquetFile('data.parquet')
   sort_order, null_placement = pq_file.sort_order
   assert sort_order == sort_keys
   assert null_placement == "at_end"
   ```


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