# Apache Parquet

**Apache Parquet** 是一种开源、面向列的数据文件格式，旨在实现高效的数据存储与检索。<sup>[1](https://parquet.apache.org/)</sup> 它将每一列的取值存放在一起，而不是按整行存储；对每一列分别施加编码与压缩；并在文件中嵌入模式与统计信息，使查询引擎只需读取查询所需的那部分列和行范围。该格式最初为 Hadoop 生态创建，如今是数据湖与湖仓（lakehouse）系统中使用的数据文件格式，并受到 [Apache Iceberg](https://www.edgepedia.org/zh/apache-iceberg) 等表格式的支持。<sup>[2](https://iceberg.apache.org/spec/)</sup>

| 关键事实 | 详情 |
|---|---|
| 是什么 | 开源、面向列的数据文件格式，用于高效存储与检索<sup>[1](https://parquet.apache.org/)</sup> |
| 起源 | Twitter 与 Cloudera 合作开发，2013 年 3 月公布；Parquet 1.0 于 2013 年 7 月 30 日发布<sup>[3](https://blog.x.com/engineering/en_us/a/2013/announcing-parquet-10-columnar-storage-for-hadoop)</sup> |
| 文件层级 | 文件 → 行组 → 列块（每列一个）→ 页，页是编码与压缩不可分割的单位<sup>[4](https://parquet.apache.org/docs/concepts/)</sup> |
| 嵌套数据 | 采用 Dremel 编码，使用定义层级与重复层级；层级本身以游程编码存储<sup>[5](https://github.com/apache/parquet-format)</sup> |
| 推荐大小 | 行组 512 MB 至 1 GB；数据页约 8 KB<sup>[5](https://github.com/apache/parquet-format)</sup> |
| 加密 | 模块化加密，采用 AES GCM、12 字节一次性数；加密文件尾的文件使用魔数字符串“PARE”而非“PAR1”<sup>[6](https://parquet.apache.org/docs/file-format/data-pages/encryption/)</sup> |
| 可变性 | Parquet 文件不可变，这促成了 Delta Lake、Apache Iceberg 和 Apache Hudi 等表格式的出现<sup>[7](https://arxiv.org/abs/2305.01120)</sup> |

## 历史

Parquet 最初是 Twitter 与 Cloudera 的合作项目，意在为 [Apache Hadoop](https://www.edgepedia.org/zh/apache-hadoop) 创建一个开源的列式存储格式库；项目于 2013 年 3 月公布，1.0 版本于 2013 年 7 月 30 日发布，自公布以来合并了 90 多个拉取请求。<sup>[3](https://blog.x.com/engineering/en_us/a/2013/announcing-parquet-10-columnar-storage-for-hadoop)</sup> 其公开目标是提供一个最先进的列式存储层，既可供现有 Hadoop 框架使用，也可供 Impala、Drill 等较新的架构使用，同时不把用户绑定到任何处理框架或序列化库上。<sup>[3](https://blog.x.com/engineering/en_us/a/2013/announcing-parquet-10-columnar-storage-for-hadoop)</sup> Parquet 进入 Apache 孵化器，并于 2014 年成为 Apache 顶级项目；迁入 Apache 之前添加的功能没有留下拉取请求记录，因为原始记录已不复存在。<sup>[8](https://parquet.apache.org/docs/file-format/versions/)</sup>

该格式对嵌套数据的处理源自谷歌的 Dremel 系统。2010 年的一篇 VLDB 论文将 Dremel 描述为一个可扩展的交互式查询系统，用于只读嵌套数据，它将多级执行树与列式数据布局结合起来，其中包括一种新颖的、面向嵌套记录的列式存储表示。<sup>[9](https://research.google/pubs/dremel-interactive-analysis-of-web-scale-datasets-2/)</sup> Parquet 规范规定，嵌套列采用 Dremel 编码，使用定义层级与重复层级。<sup>[5](https://github.com/apache/parquet-format)</sup>

## 文件结构

Parquet 文件按层级组织。文件由一个或多个行组构成，行组是数据按行进行的逻辑水平分区。每个行组中每列恰好包含一个列块，且每个列块保证在文件中连续。列块又划分为页，页在概念上是压缩与编码的不可分割单位。<sup>[4](https://parquet.apache.org/docs/concepts/)</sup> 这三个层级对应不同的并行化单位：[MapReduce](https://www.edgepedia.org/zh/mapreduce) 在文件或行组层面工作，IO 在列块层面工作，编码与压缩在页层面工作。<sup>[4](https://parquet.apache.org/docs/concepts/)</sup>

物理布局在开头放置 4 字节魔数“PAR1”，随后是各行组的列块，然后是文件元数据、该元数据的 4 字节小端长度，最后再放一个“PAR1”。文件元数据写在数据之后，以支持单遍写入，其中包含所有列块起始位置的位置信息。<sup>[10](https://parquet.apache.org/docs/file-format/)</sup> 该格式明确设计为将元数据与数据分离，这允许把列拆分到多个文件中，并由单个元数据文件引用多个 Parquet 文件。<sup>[10](https://parquet.apache.org/docs/file-format/)</sup>

项目推荐使用 512 MB 至 1 GB 的大行组，这样一行组能容纳在一个 HDFS 块内，顺序 IO 也足够大；代价是写入路径上需要更多缓冲。数据页推荐约 8 KB，因为较小的页允许更细粒度的读取。<sup>[5](https://github.com/apache/parquet-format)</sup>

## 编码、压缩与数据跳过

Parquet 支持其规范中定义的多种编码：适用于所有物理类型的 PLAIN；字典编码（已弃用的 PLAIN_DICTIONARY 由 RLE_DICTIONARY 取代）；RLE/位打包混合编码；用于整数的 DELTA_BINARY_PACKED；用于字节数据的 DELTA_LENGTH_BYTE_ARRAY 与 DELTA_BYTE_ARRAY；BYTE_STREAM_SPLIT；以及用于浮点数据的 ALP 编码。<sup>[11](https://parquet.apache.org/docs/file-format/data-pages/encodings/)</sup> 字典编码会为一个列块中遇到的取值建立字典，将其存放在数据页之前写入的字典页中，并把取值存为整数索引；如果字典变得过大，写入器会回退到普通编码。<sup>[11](https://parquet.apache.org/docs/file-format/data-pages/encodings/)</sup> 空值根本不存入数据：空值性编码在游程编码的定义层级中，因此一列 1000 个空值会被编码为单个游程。<sup>[5](https://github.com/apache/parquet-format)</sup>

在编码之上，页还可以压缩。Spark 对 Parquet 的默认压缩编解码器是 Snappy，支持的选项还包括 gzip、lzo、brotli、lz4、lz4_raw 和 zstd。<sup>[12](https://spark.apache.org/docs/latest/sql-data-sources-parquet.html)</sup>

对于[谓词下推](https://www.edgepedia.org/zh/predicate-pushdown)，读取器可以利用列块级统计信息（最小值与最大值）和字典，跳过不可能匹配过滤条件的数据。当某列的不同取值过多时，写入器可能出于空间考虑省略字典，使高基数（high-cardinality）列失去下推支持；Parquet 用分块布隆过滤器（split block Bloom filter）解决这一问题，这是它第一种、也是截至撰写本文时唯一一种布隆过滤器表示。每个块为 256 位，分为八个 32 位字，过滤器对成员查询回答“肯定没有”或“可能有”，误报概率可配置，且没有漏报。<sup>[13](https://parquet.apache.org/docs/file-format/bloomfilter/)</sup> 可选的列索引还能让读取器高效跳过页。<sup>[5](https://github.com/apache/parquet-format)</sup>

## 加密

Parquet 的模块化加密将文件中分别序列化的各个组件——页、页头、列索引、偏移索引、[布隆过滤器](https://www.edgepedia.org/zh/bloom-filter)头与位集，以及文件尾——视为可单独加密的模块。每一列和文件尾可以使用相同的密钥、不同的密钥，或不加密，只有敏感列才需要加密。该设计遵循 NIST SP 800-38D，使用 AES GCM 与 12 字节（96 位）一次性数。在加密文件尾模式下，文件使用魔数字符串“PARE”，使期待“PAR1”的旧版读取器立刻知道自己无法解析该文件；在明文文件尾模式下，文件尾经过签名而不加密，文件保留“PAR1”，让旧版读取器仍能访问未加密的列。<sup>[6](https://parquet.apache.org/docs/file-format/data-pages/encryption/)</sup> 大小开销很小：在默认 1 MB 页大小下，每 30,000 字节原始数据约增加 1 字节。<sup>[6](https://parquet.apache.org/docs/file-format/data-pages/encryption/)</sup>

## 生态系统及与其他格式的比较

Parquet 受到许多处理系统的支持；Spark SQL 读写 Parquet 时会保留原始模式，自 Spark 3.2 起，配合 Apache Parquet 1.12 及更高版本，它还支持对 Parquet 表进行列式加密。<sup>[12](https://spark.apache.org/docs/latest/sql-data-sources-parquet.html)</sup> 项目状态页列出的实现包括 [Apache Arrow](https://www.edgepedia.org/zh/apache-arrow)（C++、Go、Rust）、parquet-java、[ClickHouse](https://www.edgepedia.org/zh/clickhouse)、cuDF、hyparquet、DuckDB、Polars 和 DataHaskell。<sup>[14](https://parquet.apache.org/docs/file-format/implementationstatus/)</sup>

Parquet 是文件格式，不是表格式。由于 Parquet 文件不可变，直接在文件上频繁更新并不现实；[Delta Lake](https://www.edgepedia.org/zh/delta-lake)、Apache Iceberg 和 [Apache Hudi](https://www.edgepedia.org/zh/apache-hudi) 等日志结构表格式在不可变的 Parquet（或 ORC、Avro）数据文件之上叠加了事务、时间旅行和模式演进。<sup>[7](https://arxiv.org/abs/2305.01120)</sup> Iceberg 的规范管理由 Parquet、Avro 和 ORC 格式的不可变文件组成的表，Iceberg 自身的实现状态显示 Parquet 在其所有语言库中都受支持。<sup>[2](https://iceberg.apache.org/spec/)</sup><sup> • </sup><sup>[15](https://iceberg.apache.org/status/)</sup>

与同类格式相比，Parquet 是通用的磁盘格式，而 ORC 是作为关系型大数据系统的存储格式而构建的，Arrow 则是用于跨系统共享数据的内存格式。<sup>[16](https://link.springer.com/article/10.1007/s00778-025-00911-1)</sup> Arrow 项目直接描述了两者的搭配：Parquet 是为最大化空间效率而设计的存储格式，其数据必须解码到内存中；而 Arrow 是用于直接计算的无压缩内存布局，因此两者常一起使用——以 Parquet 存储在磁盘上，以 Arrow 进行处理。<sup>[17](https://arrow.apache.org/faq/)</sup> 2023 年一项针对 Parquet 与 ORC 的 VLDB 基准测试发现，在文件大小上总体上没有明显的赢家；Parquet 在 log 和 ml 数据集上生成的文件更小，因为它对低不同值比例的浮点列施加字典编码，而 ORC 在字典较大的字符串列上略有优势。<sup>[18](https://arxiv.org/abs/2304.05028)</sup>

## 格式演进

格式规范位于 parquet-format 仓库中，是一份 Thrift 定义，独立于 parquet-java 和 arrow-rs 等实现发布。<sup>[8](https://parquet.apache.org/docs/file-format/versions/)</sup> 新功能通过在 Parquet 开发邮件列表上讨论和投票来添加，并在下一个 parquet-format 版本中发布；版本编号不遵循语义化版本规范，因此小版本有时包含前向不兼容的功能。<sup>[8](https://parquet.apache.org/docs/file-format/versions/)</sup> 规范按兼容性对变更分类：前向兼容的新增内容，如布隆过滤器和 VARIANT 之类的逻辑类型注解，旧版读取器仍可读取，只是体验有所降级；而前向不兼容的新增内容，如新编码（DELTA_* 系列、BYTE_STREAM_SPLIT、RLE_DICTIONARY）和 Data Page V2 头，会使文件对旧版软件不可读。<sup>[8](https://parquet.apache.org/docs/file-format/versions/)</sup> parquet-format 2.10.0 版本于 2023 年 11 月 20 日发布，2.11.0 于 2025 年 3 月发布，2.14.0 于 2026 年 9 月发布。<sup>[19](https://release-catalog.apache.org/parquet-format/index.html)</sup>

## References

1. [Apache Parquet project website](https://parquet.apache.org/)
2. [Apache Iceberg Table Spec](https://iceberg.apache.org/spec/)
3. [Announcing Parquet 1.0: Columnar Storage for Hadoop, Twitter engineering blog, 30 July 2013](https://blog.x.com/engineering/en_us/a/2013/announcing-parquet-10-columnar-storage-for-hadoop)
4. [Concepts, Parquet documentation](https://parquet.apache.org/docs/concepts/)
5. [apache/parquet-format repository README](https://github.com/apache/parquet-format)
6. [Encryption, Parquet documentation](https://parquet.apache.org/docs/file-format/data-pages/encryption/)
7. [LST-Bench: Benchmarking Log-Structured Tables in the Cloud, arXiv:2305.01120](https://arxiv.org/abs/2305.01120)
8. [Parquet format versions, Parquet documentation](https://parquet.apache.org/docs/file-format/versions/)
9. [Dremel: Interactive Analysis of Web-Scale Datasets, VLDB 2010](https://research.google/pubs/dremel-interactive-analysis-of-web-scale-datasets-2/)
10. [File Format, Parquet documentation](https://parquet.apache.org/docs/file-format/)
11. [Encodings, Parquet documentation](https://parquet.apache.org/docs/file-format/data-pages/encodings/)
12. [Parquet Files, Spark SQL documentation](https://spark.apache.org/docs/latest/sql-data-sources-parquet.html)
13. [Bloom Filter, Parquet documentation](https://parquet.apache.org/docs/file-format/bloomfilter/)
14. [Implementation status, Parquet documentation](https://parquet.apache.org/docs/file-format/implementationstatus/)
15. [Implementation Status, Apache Iceberg](https://iceberg.apache.org/status/)
16. [Data formats in analytical DBMSs: performance trade-offs and future directions, VLDB Journal](https://link.springer.com/article/10.1007/s00778-025-00911-1)
17. [FAQ, Apache Arrow](https://arrow.apache.org/faq/)
18. [An Empirical Evaluation of Columnar Storage Formats, arXiv:2304.05028](https://arxiv.org/abs/2304.05028)
19. [Apache Parquet Format, Apache Release Catalog](https://release-catalog.apache.org/parquet-format/index.html)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026; Oct 25, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Data formats and serialization

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/apache-parquet

English original: https://www.edgepedia.org/apache-parquet
