XiangpengHao commented on code in PR #60: URL: https://github.com/apache/datafusion-site/pull/60#discussion_r2003499924
########## content/blog/2025-03-18-parquet-pruning.md: ########## @@ -0,0 +1,111 @@ +--- +layout: post +title: Parquet pruning in DataFusion: Read Only What Matters +date: 2025-03-18 +author: Xiangpeng Hao +categories: [performance] +--- + +<!-- +{% comment %} +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% endcomment %} +--> + + +_Editor's Note: This blog was first published on [Xiangpeng Hao's blog]. Thanks to [InfluxData] for sponsoring this work as part of his PhD funding._ + +[Xiangpeng Hao's blog]: https://blog.xiangpeng.systems/posts/parquet-to-arrow/ +[InfluxData]: https://www.influxdata.com/ +<hr/> + +Parquet has become the industry standard for storing columnar data, and reading Parquet efficiently is crucial for query performance. + +To optimize this, DataFusion implements advanced Parquet support for effective data pruning and decoding. + +However, achieving high performance adds complexity, and this is no exception. This post provides an overview of the techniques used in DataFusion to selectively read Parquet files. + +### The pipeline +The diagram below illustrates the Parquet reading pipeline in DataFusion, highlighting how data flows through various pruning stages before being converted to Arrow format: + +<img src="/blog/images/parquet-pruning/read-parquet.jpg" alt="Parquet pruning pipeline in DataFusion" width="100%" class="img-responsive"> + + +#### Background: Parquet file structure +As shown in the figure above, each Parquet file has multiple row groups. Each row group contains a set of columns, and each column contains a set of pages. + +Pages are the smallest units of data in Parquet files and typically contain compressed and encoded values for a specific column. This hierarchical structure enables efficient columnar access and forms the foundation for the pruning techniques we'll discuss. + +Check out [Querying Parquet with Millisecond Latency](https://www.influxdata.com/blog/querying-parquet-millisecond-latency/) for more details on the Parquet file structure. + +#### 1. Read metadata +DataFusion first reads the Parquet metadata to understand the data in the file. +Metadata often includes data schema, the exact location of each row group and column chunk, and their corresponding statistics (e.g., min/max values). +It also optionally includes [page-level stats](https://parquet.apache.org/docs/file-format/pageindex/) and [Bloom filters](https://www.influxdata.com/blog/using-parquets-bloom-filters/). +This information is used to prune the file before reading the actual data. + +[Fetching metadata](https://github.com/apache/datafusion/blob/31701b8dc9c6486856c06a29a32107d9f4549cec/datafusion/core/src/datasource/physical_plan/parquet/reader.rs#L118) requires up to two network requests: one to read the footer size from the end of the file, and another to read the footer itself. Review Comment: Yes, I hoped someone could do a study of "Parquet in the wild", which analyzes how people use Parquet: what features they use, how large are the metadata sizes etc. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org