Repository navigation
Add ignore_metadata_file option to read_parquet (pyarrow-dataset and fastparquet support only) - #8034
Conversation
jrbourbeau
left a comment
There was a problem hiding this comment.
Thanks @rjzamora! Pardon my ignorance about our parquet engines, but I'm curious why supporting ignore_metadata_file is more involved for fastparquet (also cc @martindurant)
You are absolutely right to ask this, because I should be able to add support for fastparquet. We will probably just need to use some variation of |
|
Update: Thanks for the reivew here @jrbourbeau ! I addressed your comments, and added "fastparquet" support here. So, hopefully this PR is in good shape (once CI is passing). |
martindurant
left a comment
There was a problem hiding this comment.
At a quick glance, the fp route looks OK, but first I wonder: should we explicitly disallow the combination of ignore_metadata_file with gather_statistics?
| # This is a directory. | ||
| # Check if _metadata and/or _common_metadata files exists | ||
| base = paths[0] | ||
| _metadata_exists = fs.isfile(fs.sep.join([base, "_metadata"])) |
There was a problem hiding this comment.
If ignore_metadata_file, then we know we will have to list the whole directory anyway, so we can avoid the calls to isfile and even isdir, above.
There was a problem hiding this comment.
Good point - I just pushed a change to avoid the isfile calls. However, it seems like we may need to move around the logic quite a bit to avoid the isdir call. In fact, I'm nor really sure of an elegant way to avoid it.
My vote is "no" - I don't think a willingness to ignore the shared _metadata file means the user should not be able to gather statistics. After #8058, there may even be cases where a parallel |
jrbourbeau
left a comment
There was a problem hiding this comment.
Woo, thanks for adding ignore_metadata_file support to fastparquet!
| # Should not have known divisions if gather_statistics=None | ||
| # Otherwise, we must have used a _metadata file | ||
| assert set(ddf2.divisions) == {None} |
There was a problem hiding this comment.
This seems fine, but I wonder if there's a more direct check we can have that _metadata wasn't used. For example, we could manually delete the _metadata file before calling read_parquet
There was a problem hiding this comment.
Without the file, we would presumably get the same behaviour whether you have ignore-metadata true or false.
There was a problem hiding this comment.
I updated the test to do something pretty simple: We write two datasets (one with _metadata, and one without), and check that the result is the same with ignore_metadata_file=True. How does that sound?
There was a problem hiding this comment.
I'll defer to you two on this test. I think I still need to wrap my head around how we handle gathering metadata and how that translates to division information on the resulting DataFrame. If you two are happy with this, then let's go with it
There was a problem hiding this comment.
Another option might be to create a dataset with a "wrong" _metadata file (eg only listing a subset of the files, or simply an invalid parquet file), and then reading it with ignore_metadata_file, you can be sure it was not used if you get the correct result.
There was a problem hiding this comment.
That's the answer, thanks @jorisvandenbossche - replace the _metadata file with something invalid (perhaps empty?)
Co-authored-by: James Bourbeau <[email protected]>
|
Just checking in, @rjzamora @martindurant is there anything else left to address here, or are we good to merge? Also cc @jorisvandenbossche for visibility |
|
Thanks for the test update @rjzamora -- I feel confident we're effectively testing that |
Yikes. I'd rather not ignore a failure in |
Sounds like an odd one, we can pair to figure this out, if you like. |
|
@martindurant - Are you able to reproduce the failure locally? I'm not sure how any of the fastparquet-engine changes could be causing this. |
|
Passes with dask main/fastparquet main Since it's only coming up on one build, could it be some combination of the random numbers, e.g., one of the specific sub-directories ends up empty? |
|
I ran with |
|
Just checking in, any luck reproducing? I'm inclined to merge if we're not able to and just keep an eye on |
No luck reproducing on my end. We may have some problematic behavior to fix, but I suspect it is not being caused by this PR. |
|
Alright, thanks for your efforts on trying to reproduce @rjzamora @martindurant. I'll plan to merge this later in the evening if there aren't any objections |
May address #8030
This PR makes it possible to ignore a global _metadata file using the
ignore_metadata_fileargument:Note that I did not add support for fastparquet or pyarrow-legacy (they will both raise an error ifignore_metadata_file=True), only because it is much trickier to implement for those engines (and because the pyarrow-legacy engine will be deprecated soon anyway).EDIT: This PR now adds
ignore_metadata_filesupport for both "pyarrow-datset" and "fastparquet". The "pyarrow-legacy" case still doesn't make much sense because: (1) it is deprecated, and (2) the engine will still construct a proxy _metadata file anyway.