fix(streaming-write): use rolling ParquetWriter + OutputStream.tell() for spec-correct file sizes and bounded memory
还没有人认领这个 Issue。
评估
调研方向
从 RecordBatchReader 输入的 Table.append/Table.overwrite 开始,跟踪 bin_pack_record_batches 路径,然后阅读提议的 pq.ParquetWriter 和 OutputStream.tell() 用法。完成的标准是 target_file_size_bytes 反映压缩后的磁盘大小,并且在不更改 public API 的情况下保持内存有界;issue 未指定测试文件。
由索引模型根据 Issue 内容生成。
描述
Background
PR #3335 added pa.RecordBatchReader as a valid input to Table.append/Table.overwrite using a buffered bin-pack approach (bin_pack_record_batches). That implementation has two acknowledged caveats called out in its docstrings:
- Memory bound: peak memory is
N_workers × write.target-file-size-bytes(~4 GiB at defaults) — better than materialising everything, but not constant. - Byte semantics:
write.target-file-size-bytesis interpreted as uncompressed in-memory Arrow bytes, not on-disk compressed Parquet bytes. Resulting files are typically 3–10× smaller than the property suggests — diverging from the Java/Spark/Flink writers.
Proposed fix
Replace the bin-pack approach with a rolling pq.ParquetWriter driven by OutputStream.tell() (added in #2998 specifically for this purpose):
with output_file.create(overwrite=True) as fos:
with pq.ParquetWriter(fos, schema=..., ...) as writer:
writer.write_batch(first_batch)
while fos.tell() < target_file_size: # ← compressed on-disk bytes
batch = next(batches)
writer.write_batch(batch)
This delivers:
- Spec-correct file sizes:
tell()reports compressed on-disk bytes, sowrite.target-file-size-bytesfinally means what the Iceberg spec intends — consistent with the Java/Spark/Flink writers. - Truly bounded memory: peak RSS is bounded by one input batch + Parquet page buffer (~1 MiB × columns) + S3 multipart pool (~5 MiB × ~8 parts), regardless of
target_file_size, dataset size, or number of files produced. - No public API change: same
tbl.append(reader)/tbl.overwrite(reader)interface.
Fix
#3336
- 主要语言
- Python
- 星标
- 1.1k
- 派生
- 589
- 平均合并
- 2 天 2 小时
- 30 天内合并 PR
- 70
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/iceberg-python 的其他 Issue
-
kind:bug
难度 1/5 1 小时以内 新手友好度 92/100
apache/iceberg-python#4006 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
apache/iceberg-python#3996 ·
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
apache/iceberg-python#3979 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
apache/iceberg-python#3885 ·
-
[Bug] PyArrowFileIO fails to propagate s3.ssl.ca-cert to pyarrow.fs.S3FileSystem tls_ca_file_path 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
apache/iceberg-python#3866 · 1 条评论 ·
查看 apache/iceberg-python 的全部 Issue
相似的 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 70/100
canonical/paas-charm#368 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
tech debt
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 1/5 1 小时以内 新手友好度 90/100
StevenBlack/hosts#3256 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
qualcomm/qai-appbuilder#275 ·