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
For large Parquet datasets, loading the consolidated _metadata file, especially when it's a remote file, can be quite slow. We should consider adding an flag to optionally disable reading _metadata. Initially I thought setting gather_statistics=False would do this, but that turned out to not be the case (at least for the pyarrow-dataset and fastparquet engines)
cc @rjzamora in case you have thoughts on this topic
I agree that we should make it possible to avoid reading _metadata if there are fundamental limits in pyarrow for parsing the file.
Other (somewhat-related) thoughts...
I also think we should try to decentralize the read_parquet "planning" stage a bit. Note that I am working on a (second) refactor of the read_orc API in #8004, where I am breaking up the typical "read_metadata" stage, and I am getting the feeling that we need something very similar for parquet. More specifically, I think the "planning stage" of read_parquet should follow three stages:
Stage 1: Get general dataset information. In this stage, we use pyarrow/fastparquet to populate a dictionary of general dataset information. The engine can use the _metadata file by default, but we should also make it possible to ignore this file if desired. Note that this stage should be "fast," so it should not dig into the data or file statistics.
Stage 2: Construct output meta. Once we have general dataset information, we should be able to construct the meta without reading in any data, parsing parquet metadata/statistics, or constructing list of output partitions. Calculating the meta separately and early like this should also benefit the high-level expression plans discussed in #7933.
Stage 3: Construct an output-partition plan. This is the stage where the heavy lifting is done, because we need to construct a list of path/row-group-range combinations for every output partition. In the current arrow engine, we effectively start this process by constructing a global "parquet metadata" object. When _metadata is not present, we can do this in parallel on the workers, but we always end up processing the global metadata on the client. This is because we rely on "shared"/"core" Dask logic to process the statistics, apply filters, and calculate divisions. However, if we move the stats/filtering/divisions responsibility onto the engine, the entire output-partition plan process can be parallelized pretty easily. Overall, I am vaguely suggesting that we bite the bullet and move the statistics-related logic into the engine. The engine implementations can still call shared utilities.
Stage 1: Get general dataset information. ... The engine can use the _metadata file by default, but we should also make it possible to ignore this file if desired. Note that this stage should be "fast," so it should not dig into the data or file statistics.
I suppose the idea is that the meta can be constructed exclusively with information gathered here?
I am wondering how you can do that with the current parquet datasets written by dask without either parsing a metadata file or either reading one single parquet data file + doing a filesystem scan (which can also be costly).
For example to discover the partitioning (know which fields need to be added to the schema as partition columns), you need to know something about the directory structure? (which can either be read from the metadata file, or either requires a filesystem scan, with the current information stored in the dataset?)
Stage 1: Get general dataset information. ... The engine can use the _metadata file by default, but we should also make it possible to ignore this file if desired. Note that this stage should be "fast," so it should not dig into the data or file statistics.
I suppose the idea is that the meta can be constructed exclusively with information gathered here?
I am wondering how you can do that with the current parquet datasets written by dask without either parsing a metadata file or either reading one single parquet data file + doing a filesystem scan (which can also be costly).
For example to discover the partitioning (know which fields need to be added to the schema as partition columns), you need to know something about the directory structure? (which can either be read from the metadata file, or either requires a filesystem scan, with the current information stored in the dataset?)
You are 100% correct - This step cannot always be "fast", and I am still unsure of the best way to handle the case where we don't have a _metadata file, or that _metadata file is too large. What I do know is that we will want to be able to calculate the DataFrame._meta before starting the build the graph (gather/process parts/statistics), because we may use the high-level expressions for predicate pushdown/column-projection after the metadata is first generated. When we can assume that the dataset is not hive/directory partitioned, this is easy - Otherwise, we do need to do some up-front work to capture the correct metadata.
On Fri, Aug 13, 2021 at 8:13 AM Richard (Rick) Zamora < ***@***.***> wrote:
Stage 1: Get general dataset information. ... The engine can use the
_metadata file by default, but we should also make it possible to ignore
this file if desired. Note that this stage should be "fast," so it should
not dig into the data or file statistics.
I suppose the idea is that the meta can be constructed exclusively with
information gathered here?
I am wondering how you can do that with the current parquet datasets
written by dask without either parsing a metadata file or either reading
one single parquet data file + doing a filesystem scan (which can also be
costly).
For example to discover the partitioning (know which fields need to be
added to the schema as partition columns), you need to know something about
the directory structure? (which can either be read from the metadata file,
or either requires a filesystem scan, with the current information stored
in the dataset?)
You are 100% correct - This step cannot always be "fast", and I am still
unsure of the best way to handle the case where we don't have a _metadata
file, or that _metadata file is too large. What I do know is that we will
want to be able to calculate the DataFrame._meta before starting the
build the graph (gather/process parts/statistics), because we may use the
high-level expressions for predicate pushdown/column-projection after the
metadata is first generated. When we can assume that the dataset is not
hive/directory partitioned, this is easy - Otherwise, we do need to do some
up-front work to capture the correct metadata.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8030 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKZTG6KEDQRTYB5ATDNBTT4UK7TANCNFSM5CCKW3WQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
I recently upgraded to 2021.8.0 and got this error. After reverting back to 2021.7.2 the issue seems to have gone away. I see there is a PR 8034 open for this already but if an extra set of hands are needed, I'm happy to contribute. I will try to test the changes in PR 8034 to see if they fix my issue as well.
Thanks for all the great work!
Stage 3: Construct an output-partition plan. This is the stage where the heavy lifting is done, because we need to construct a list of path/row-group-range combinations for every output partition. In the current arrow engine, we effectively start this process by constructing a global "parquet metadata" object. When _metadata is not present, we can do this in parallel on the workers, but we always end up processing the global metadata on the client. This is because we rely on "shared"/"core" Dask logic to process the statistics, apply filters, and calculate divisions. However, if we move the stats/filtering/divisions responsibility onto the engine, the entire output-partition plan process can be parallelized pretty easily. Overall, I am vaguely suggesting that we bite the bullet and move the statistics-related logic into the engine. The engine implementations can still call shared utilities.
In general I support parallelizing metadata harvesting and construction. FWIW I think that Spark also does this (there appears to be a small compute period when they read a dataset).
I'm curious about moving statistics functionality out of core. My current sense is that the remote-vs-local choice doesn't necessarily have to trigger a change of responsibility from core code to engine code. Is this understanding correct?
@iameskild that doesn't seem directly related. It is an error coming from parsing the _metadata file, and so having an option to not use that file (what this issue is about) would also help for your case as a workaround. But the fact that you get an error reading this file should have some cause / is a bug (for which I would recommend opening a separate issue).
I'm curious about moving statistics functionality out of core. My current sense is that the remote-vs-local choice doesn't necessarily have to trigger a change of responsibility from core code to engine code. Is this understanding correct?
Yes. Your understanding is correct - but the exact separation between “core” and “engine” logic already varies a bit among engine implementation.
Right now, the read_parquet logic starts by asking the engine to read and process the dataset and all relevant parquet metadata (in engine.read_metadata). This classmethod is expected to produce the output meta, a list of information needed to produce each output partition (parts), and a corresponding list of statistics (statistics). The engine is already free to use compute within this class method to compile parts/statistics remotely. The "pyarrow-legacy" engine does parallelize the harvesting/construction of a global parquet-metadata object when the _metadata file is missing, but the construction of parts/statistics still occurs on the client.
It wouldn't be a significant change to implement parallel-construction of parts/statistics. As you suggested, it does not require any official "change of responsibility" from core code to engine code. However, the current separation of "responsibilities" requires that we follow up the read_metadata call with a second (optional) pass over the parts/statistics (on the client) to perform filtering, and then a third (optional) pass to perform part/file aggregation. We could certainly make the filtering logic remote without making it the responsibility of the engine, or refactor things so that "core" filtering is done in parallel. However, the "core" filtering pass is already being skipped by "pyarrow-dataset," because the row-groups/partitions are already filtered during dataset-fragment discovery.
Therefore, my general suggestion here is that we may want to stop "pretending" like filtering is "core" logic when it already isn’t. We can maintain general/shared filtering utilities, but pushing the official responsibility into the engine actually feels like an easier-to-maintain solution to me.
Activity
rjzamora commentedon Aug 13, 2021
I agree that we should make it possible to avoid reading _metadata if there are fundamental limits in pyarrow for parsing the file.
Other (somewhat-related) thoughts...
I also think we should try to decentralize the read_parquet "planning" stage a bit. Note that I am working on a (second) refactor of the read_orc API in #8004, where I am breaking up the typical "
read_metadata" stage, and I am getting the feeling that we need something very similar for parquet. More specifically, I think the "planning stage" ofread_parquetshould follow three stages:Stage 1: Get general dataset information. In this stage, we use pyarrow/fastparquet to populate a dictionary of general dataset information. The engine can use the
_metadatafile by default, but we should also make it possible to ignore this file if desired. Note that this stage should be "fast," so it should not dig into the data or file statistics.Stage 2: Construct output
meta. Once we have general dataset information, we should be able to construct themetawithout reading in any data, parsing parquet metadata/statistics, or constructing list of output partitions. Calculating themetaseparately and early like this should also benefit the high-level expression plans discussed in #7933.Stage 3: Construct an output-partition plan. This is the stage where the heavy lifting is done, because we need to construct a list of path/row-group-range combinations for every output partition. In the current arrow engine, we effectively start this process by constructing a global "parquet metadata" object. When _metadata is not present, we can do this in parallel on the workers, but we always end up processing the global metadata on the client. This is because we rely on "shared"/"core" Dask logic to process the statistics, apply filters, and calculate divisions. However, if we move the stats/filtering/divisions responsibility onto the engine, the entire output-partition plan process can be parallelized pretty easily. Overall, I am vaguely suggesting that we bite the bullet and move the statistics-related logic into the engine. The engine implementations can still call shared utilities.
jorisvandenbossche commentedon Aug 13, 2021
I suppose the idea is that the
metacan be constructed exclusively with information gathered here?I am wondering how you can do that with the current parquet datasets written by dask without either parsing a metadata file or either reading one single parquet data file + doing a filesystem scan (which can also be costly).
For example to discover the partitioning (know which fields need to be added to the schema as partition columns), you need to know something about the directory structure? (which can either be read from the metadata file, or either requires a filesystem scan, with the current information stored in the dataset?)
rjzamora commentedon Aug 13, 2021
You are 100% correct - This step cannot always be "fast", and I am still unsure of the best way to handle the case where we don't have a _metadata file, or that _metadata file is too large. What I do know is that we will want to be able to calculate the
DataFrame._metabefore starting the build the graph (gather/process parts/statistics), because we may use the high-level expressions for predicate pushdown/column-projection after the metadata is first generated. When we can assume that the dataset is not hive/directory partitioned, this is easy - Otherwise, we do need to do some up-front work to capture the correct metadata.mrocklin commentedon Aug 13, 2021
rjzamora commentedon Aug 13, 2021
Yes - This will do the trick in most cases, but it will not capture directory-partitioned columns.
iameskild commentedon Aug 16, 2021
Hi folks, this might the same issue I'm currently experiencing, here is the error message I see when we call
read_parquet(spatialpandas, using pyarrow v0.3.0):I recently upgraded to
2021.8.0and got this error. After reverting back to2021.7.2the issue seems to have gone away. I see there is a PR 8034 open for this already but if an extra set of hands are needed, I'm happy to contribute. I will try to test the changes in PR 8034 to see if they fix my issue as well.Thanks for all the great work!
mrocklin commentedon Aug 17, 2021
In general I support parallelizing metadata harvesting and construction. FWIW I think that Spark also does this (there appears to be a small compute period when they read a dataset).
I'm curious about moving statistics functionality out of core. My current sense is that the remote-vs-local choice doesn't necessarily have to trigger a change of responsibility from core code to engine code. Is this understanding correct?
jorisvandenbossche commentedon Aug 17, 2021
@iameskild that doesn't seem directly related. It is an error coming from parsing the
_metadatafile, and so having an option to not use that file (what this issue is about) would also help for your case as a workaround. But the fact that you get an error reading this file should have some cause / is a bug (for which I would recommend opening a separate issue).rjzamora commentedon Aug 17, 2021
Yes. Your understanding is correct - but the exact separation between “core” and “engine” logic already varies a bit among engine implementation.
Right now, the
read_parquetlogic starts by asking the engine to read and process the dataset and all relevant parquet metadata (inengine.read_metadata). This classmethod is expected to produce the outputmeta, a list of information needed to produce each output partition (parts), and a corresponding list of statistics (statistics). The engine is already free to usecomputewithin this class method to compileparts/statisticsremotely. The "pyarrow-legacy" engine does parallelize the harvesting/construction of a global parquet-metadata object when the _metadata file is missing, but the construction ofparts/statisticsstill occurs on the client.It wouldn't be a significant change to implement parallel-construction of
parts/statistics. As you suggested, it does not require any official "change of responsibility" from core code to engine code. However, the current separation of "responsibilities" requires that we follow up theread_metadatacall with a second (optional) pass over theparts/statistics(on the client) to perform filtering, and then a third (optional) pass to perform part/file aggregation. We could certainly make the filtering logic remote without making it the responsibility of the engine, or refactor things so that "core" filtering is done in parallel. However, the "core" filtering pass is already being skipped by "pyarrow-dataset," because the row-groups/partitions are already filtered during dataset-fragment discovery.Therefore, my general suggestion here is that we may want to stop "pretending" like filtering is "core" logic when it already isn’t. We can maintain general/shared filtering utilities, but pushing the official responsibility into the engine actually feels like an easier-to-maintain solution to me.
jrbourbeau commentedon Aug 24, 2021
Closing this issue as an
ignore_metadata_fileoption was added in #8034 and @rjzamora opened #8058 to discuss improving metadata processing