Skip to content

ENH: Preserve DataFrame divisions when reading from parquet using pyarrow #3383

Closed

Description

@jonmmease

Discussion of the issue is captured well in this SO post: https://stackoverflow.com/questions/48104325/preserving-dask-dataframe-divisions-in-parquet

When a dataframe with known divisions is saved to parquet, and then read back from parquet using the pyarrow engine, the division information is not preserved.

df.divisions # [1, 2, 3, ...]
df.to_parquet('frame.pq', engine='pyarrow', write_index=True)
df2 = dask.dataframe.read_parquet('frame.pq', engine='pyarrow')
df2.divisions # [None, None, ...]

(I can make the example reproducible if the description isn't sufficiently clear)

From a quick glance at the _read_pyarrow function it seems that there's currently no attempt to identify the division information when reading parquet using pyarrow: https://github.com/xhochy/dask/blob/ef6a1aa2444bd5dcf79774808bb0dbc25e456a34/dask/dataframe/io/parquet.py#L575.

Activity

  1. mrocklin commented on Apr 6, 2018

    @mrocklin
    Member
  2. jcrist commented on Apr 6, 2018

    @jcrist
    Member

    there's currently no attempt to identify the division information when reading parquet using pyarrow

    This wasn't possible before arrow 0.9.0 (recent release), but now is kind of possible. Arrow still doesn't write a single metadata file, but the statistics are now available via the python bindings, so a full scan of all parquet files in a dataset could allow for recovering the divisions.

  3. jonmmease commented on Apr 6, 2018

    @jonmmease
    ContributorAuthor

    I'll probably play around with this a bit over the weekend. I need to come up with at least a workaround soon.

    @jcrist @mrocklin Should there be any API changes when divisions support is added? Or, would it be acceptable to simply return a DataFrame with known divisions when possible (e.g. when the parquet dataset has the right structure and pyarrow >=0.9.0 is available)?

  4. jcrist commented on Apr 6, 2018

    @jcrist
    Member

    Should there be any API changes when divisions support is added?

    No, this should just work the same as with the fastparquet engine when possible. No need to change the api.

    I'll probably play around with this a bit over the weekend.

    PRs definitely welcome :).

  5. mrocklin commented on Apr 7, 2018

    @mrocklin
    Member

    I think that there is an active question of if we should do this or not. Looking through the metadata of each of the parquet files individually might be expensive, particularly if they are remote.

  6. jcrist commented on Apr 17, 2018

    @jcrist
    Member

    Fixed by #3387. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions