Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for partitioned parquet #47

Open
aecorn opened this issue Feb 14, 2023 · 0 comments
Open

Support for partitioned parquet #47

aecorn opened this issue Feb 14, 2023 · 0 comments

Comments

@aecorn
Copy link
Collaborator

aecorn commented Feb 14, 2023

On request from @ohvssb
@BjornRoarJoneid also probably has some interest.

Partitioned parquet is possible on google cloud, and it can be filtered on a row basis on-read for faster loading. For the larger datasets it would be a possibility to avoid transitioning to databases potentially.

To write to to a partitioned dataset is pretty simple:

  • pyarrow.Table.from_pandas(df)
  • outpath
  • partition_cols=['FODT_AAR']
  • filesystem = gcs_file_system

To get back to an ordinary pandas dataframe is a bit harder, you would have to:

  • decide the filter to apply on the partitioned columns, like filters=[('FODT_AAR', '>', 1995)]
  • read().combine_chunks() on the pyarrow.parquet.ParquetDataset
  • set the column used as the partitioned_cols back into the data, with an appropriate datatype (an other option is to duplicate it, before writing it down, which is probably simpler but adds data)
  • doing a .to_pandas() on the pyarrow dataset

Here is an experiment:
https://github.com/statisticsnorway/utd_nudb/blob/carl_experiments_daplaprod/experiments/partition_parquet.ipynb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant