You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] Specifying schema does not prevent arrow from reading metadata on every single parquet? #34145
This takes a whooping 102 seconds on my machine. I believe most of the computation is associated with checking the metadata found in each parquet file, since there are many individual partitions in this data. This process should not be necessary though if we provide the schema:
I would have expected similar performance between these two cases: ds.dataset() should just be establishing a connection with the schema and not reading any data. After all part of the promise of partitioned data is that we could open the dataset at the root of the parquet db and rely on filtering operations to extract a specific subset without the code ever touching all the other parquet files.
My guess here is that arrow is trying to read all the parquet file metadata to ensure they all match the schema, even though that is not the expected behavior. I think this is the same issue as seen in R #33312. But maybe I'm not doing something correct or miss-understand the expected behavior?
def discover_dataset(directory):
files = list_files_recursive(directory)
if unify_schemas:
return unify([get_schema(file) for file in files])
else:
return get_schema(files[0])
I think the problem is that all of this time is being spent in list_files_recursive. There may be two problems:
Looking at the code, if there is a lot of nesting in the dataset, we may be doing too many list objects calls because I think list objects is inherently recursive.
Even if we are not doing too many list objects calls we should be able to abort early if we know we only want one file.
Ok. I've filed #34213 for #1. I suspect, if that is solved, #2 won't be very noticeable until you have tens of thousands of files. Either way we can leave this issue open for addressing #2.
Is it possible somehow to order ds.dataset(...) to not run its discovery/schema inference procedure?
This procedure is taking way too long when the dataset folder contains thousands of files.
I tried passing schema and exclude_invalid_files=False but it does not help.
Activity
westonpace commentedon Feb 15, 2023
The discovery code is roughly:
I think the problem is that all of this time is being spent in
list_files_recursive. There may be two problems:I'm going to investigate
#1a bit.westonpace commentedon Feb 15, 2023
Ok. I've filed #34213 for
#1. I suspect, if that is solved,#2won't be very noticeable until you have tens of thousands of files. Either way we can leave this issue open for addressing#2.yonil7 commentedon Oct 20, 2023
Is it possible somehow to order
ds.dataset(...)to not run its discovery/schema inference procedure?This procedure is taking way too long when the dataset folder contains thousands of files.
I tried passing
schemaandexclude_invalid_files=Falsebut it does not help.thisisnic commentedon Nov 9, 2026
Appears to have been fixed in #34213