Skip to content

Regression: read_parquet fails on main (not on 2021.10.0) #8349

Closed

Description

@jsignell

There is a regression on main that causes the following to fail. I discovered this while looking at #8323

import numpy as np
import pandas as pd
import dask.dataframe as dd

np.random.seed(1)
df = pd.DataFrame(np.random.randint(0, 10, size=(10, 4)), columns=['a', 'b', 'c', 'd']).set_index(['a', 'b']).sort_index()
df.to_parquet("multi.pq", engine='fastparquet')
dd.read_parquet("multi.pq").compute()
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-4-79a798c099ae> in <module>
      6 df = pd.DataFrame(np.random.randint(0, 10, size=(10, 4)), columns=['a', 'b', 'c', 'd']).set_index(['a', 'b']).sort_index()
      7 df.to_parquet("multi.pq", engine='fastparquet')
----> 8 dd.read_parquet("multi.pq").compute()

~/dask/dask/dataframe/io/parquet/core.py in read_parquet(path, columns, filters, categories, index, storage_options, engine, gather_statistics, ignore_metadata_file, metadata_task_size, split_row_groups, chunksize, aggregate_files, **kwargs)
    324         gather_statistics = True
    325 
--> 326     read_metadata_result = engine.read_metadata(
    327         fs,
    328         paths,

~/dask/dask/dataframe/io/parquet/fastparquet.py in read_metadata(cls, fs, paths, categories, index, gather_statistics, filters, split_row_groups, chunksize, aggregate_files, ignore_metadata_file, metadata_task_size, **kwargs)
    849 
    850         # Stage 1: Collect general dataset information
--> 851         dataset_info = cls._collect_dataset_info(
    852             paths,
    853             fs,

~/dask/dask/dataframe/io/parquet/fastparquet.py in _collect_dataset_info(cls, paths, fs, categories, index, gather_statistics, filters, split_row_groups, chunksize, aggregate_files, ignore_metadata_file, metadata_task_size, require_extension, **kwargs)
    455                 # Will need to pass a list of paths to read_partition
    456                 scheme = get_file_scheme(fns)
--> 457                 pf = ParquetFile(paths[:1], open_with=fs.open, root=base, **kwargs)
    458                 pf.file_scheme = scheme
    459                 pf.cats = paths_to_cats(fns, scheme)

~/conda/envs/dask-dev/lib/python3.9/site-packages/fastparquet/api.py in __init__(self, fn, verify, open_with, root, sep, fs, pandas_nulls)
    103             fs = getattr(open_with, "__self__", None)
    104         if isinstance(fn, (tuple, list)):
--> 105             basepath, fmd = metadata_from_many(fn, verify_schema=verify,
    106                                                open_with=open_with, root=root,
    107                                                fs=fs)

~/conda/envs/dask-dev/lib/python3.9/site-packages/fastparquet/util.py in metadata_from_many(file_list, verify_schema, open_with, root, fs)
    177                     raise ValueError('Incompatible schemas')
    178 
--> 179         fmd = copy.copy(pfs[0].fmd)  # we inherit "created by" field
    180         fmd.row_groups = []
    181 

IndexError: list index out of range

ping @martindurant and @rjzamora

Activity

  1. changed the title [-]Regression: read from parquet file fails on main (not on 2021.10.0)[/-] [+]Regression: `read_parquet` fails on main (not on 2021.10.0)[/+] on Nov 5, 2021
  2. martindurant commented on Nov 5, 2021

    @martindurant
    Member

    Detail:
    fastparquet alone reads this fine, but I see that in the dask code in _collect_dataset_info we are passing an empty list of paths for fastparquet to handle

  3. martindurant commented on Nov 5, 2021

    @martindurant
    Member

    Note that the data is a single file, not a directory. If it is renamed "multi.parquet", it works OK - so we are failing the file names filter, which should not apply to a single file input.

  4. rjzamora commented on Nov 5, 2021

    @rjzamora
    Member

    Thanks for raising @jsignell , and @martindurant for taking a look. I can work on a fix later today

  5. jsignell commented on Nov 5, 2021

    @jsignell
    MemberAuthor

    sorry if the title was too alarmist 😬 seems like it is kind of an edge case.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions