Skip to content

require_extension regression in read_parquet #8491

Closed

Description

@TomAugspurger

This example requires adlfs and planetary-computer (pip install adlfs planetary-computer)

>>> import dask.dataframe as dd, planetary_computer
>>> credential = planetary_computer.sas.get_token("ai4edataeuwest", "gbif").token
>>> dd.read_parquet('abfs://gbif/occurrence/2021-10-01/occurrence.parquet', storage_options=dict(account_name="ai4edataeuwest", credential=credential))

This raises with

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-3665ff1dc1a7> in <module>
      1 import dask.dataframe as dd, planetary_computer
      2 credential = planetary_computer.sas.get_token("ai4edataeuwest", "gbif").token
----> 3 dd.read_parquet('abfs://gbif/occurrence/2021-10-01/occurrence.parquet', storage_options=dict(account_name="ai4edataeuwest", credential=credential))

~/src/dask/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,

~/src/dask/dask/dask/dataframe/io/parquet/arrow.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)
    328
    329         # Stage 1: Collect general dataset information
--> 330         dataset_info = cls._collect_dataset_info(
    331             paths,
    332             fs,

~/src/dask/dask/dask/dataframe/io/parquet/arrow.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, **dataset_kwargs)
    827                 ]
    828                 if len0 and paths == []:
--> 829                     raise ValueError(
    830                         "No files satisfy the `require_extension` criteria "
    831                         f"(files must end with {require_extension})."

ValueError: No files satisfy the `require_extension` criteria (files must end with ('.parq', '.parquet')).

Related to #8349. Is this a deliberate change and I'll need to update the code? Or is it unintentonal?

In case it helps, here's the directory structure:

In [5]: import adlfs

In [6]: fs = adlfs.AzureBlobFileSystem("ai4edataeuwest", credential=credential)
In [8]: fs.ls("gbif/occurrence/2021-10-01")
Out[8]:
['gbif/occurrence/2021-10-01/citation.txt',
 'gbif/occurrence/2021-10-01/occurrence.parquet']

In [9]: fs.ls("gbif/occurrence/2021-10-01/occurrence.parquet")[:10]
Out[9]:
['gbif/occurrence/2021-10-01/occurrence.parquet/000000',
 'gbif/occurrence/2021-10-01/occurrence.parquet/000001',
 'gbif/occurrence/2021-10-01/occurrence.parquet/000002',
 'gbif/occurrence/2021-10-01/occurrence.parquet/000003',
 'gbif/occurrence/2021-10-01/occurrence.parquet/000004',
 'gbif/occurrence/2021-10-01/occurrence.parquet/000005',
 'gbif/occurrence/2021-10-01/occurrence.parquet/000006',
 'gbif/occurrence/2021-10-01/occurrence.parquet/000007',
 'gbif/occurrence/2021-10-01/occurrence.parquet/000008',
 'gbif/occurrence/2021-10-01/occurrence.parquet/000009']

cc @rjzamora.

Activity

  1. TomAugspurger commented on Dec 15, 2021

    @TomAugspurger
    MemberAuthor

    Reading through things a bit more closely, and looking at that file structure, I guess this might be the expected behavior?

    I'm not seeing require_extension documented anywhere. IIUC it's passed through like read_parquet(..., dataset={"required_extension": None}). I don't see dataset documented either. Is that a pyarrow specific keyword, or can it be added as a top-level keyword argument?

  2. rjzamora commented on Dec 15, 2021

    @rjzamora
    Member

    Reading through things a bit more closely, and looking at that file structure, I guess this might be the expected behavior?

    Ah - Right. You will need to disable the required file extensions if you only specify a directory (without a _metadata) file. This behavior was added for Spark compatibility.

    I'm not seeing require_extension documented anywhere. IIUC it's passed through like read_parquet(..., dataset={"required_extension": None}). I don't see dataset documented either. Is that a pyarrow specific keyword, or can it be added as a top-level keyword argument?

    I think the lack of required_extension documentation is a mistake, and the documentation for dataset "exists", but is pretty terrible. Note that #8339 improves the 'dataset' description slightly, but the real problem is that the read= and dataset= parqameters are described under kwargs (which doesn't really makes much sense at all).

    Perhaps it would be best to add explict dataset_options and read_options arguments, with dedicated documentation? (For backward compatibility, we can redirect read/dataset arguments when they are still specified).

  3. TomAugspurger commented on Dec 16, 2021

    @TomAugspurger
    MemberAuthor

    Thanks. So to confirm, if I added a _metadata file then the additional keyword arguments wouldn't be necessary?

    Perhaps it would be best to add explict dataset_options and read_options arguments, with dedicated documentation? (For backward compatibility, we can redirect read/dataset arguments when they are still specified).

    Yeah, I think that's a great idea. I can take that on if you want, though perhaps #8339 should go in first.

  4. rjzamora commented on Dec 16, 2021

    @rjzamora
    Member

    I can take that on if you want, though perhaps #8339 should go in first.

    If you are motivated to do it soon, then don't worry too much about #8339 (I don't mind revising it if needed) :)

  5. added
    needs attention
    on Jan 17, 2022
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

    dataframeioneeds attentionparquet

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions