Offset overflow - Native Parquet scan expands flat dictionary columns and reads twice Spark's batch rows

未关闭
#7,499 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
rust, scala, spark

调研方向

Start with the native Parquet scan and the arrow-rs byte-array decoding paths described in the issue, including the DELTA_LENGTH_BYTE_ARRAY decoder. Reproduce the overflow with a flat dictionary-encoded string column and a small injected byte budget, then compare native scan results with Spark's reader. Done means byte-bounded batching or dictionary handling prevents overflow while preserving the expected rows; the issue also calls out matching Spark's default batch size and an upstream decoder panic fix.

由索引模型根据 Issue 内容生成。

描述

area:scan bug priority:medium

Part of #7267.

Problem

Two things make the native Parquet scan, and the native Iceberg scan that uses the same arrow-rs reader, overflow a string or binary column where Spark's reader does not.

Flat dictionary-encoded columns are expanded per batch. Comet asks arrow-rs for plain Utf8/Binary, so the reader copies a dictionary value into the batch once per row that references it (extend_from_dictionary, parquet 59.3.2 src/arrow/buffer/offset_buffer.rs:92-118). A column with a few wide distinct values is stored as a small dictionary page plus tiny keys, and can still expand past 2 GiB in one 8192-row batch: one 300 KB value repeated 8192 times is 2.4 GB. The scan fails with index overflow decoding byte array. Spark's vectorized reader keeps the dictionary ids and decodes a value only when a row reads it, so it succeeds. #7254 covers the nested case; flat columns overflow inside arrow-rs instead.

Twice the rows per batch. Comet reads spark.comet.batchSize rows per batch, 8192 by default. Spark's vectorized Parquet reader reads spark.sql.parquet.columnarReaderBatchSize rows (4096), and Iceberg's Java reader 5000. With values of 256-512 KiB in row groups large enough to fill a batch (large row-group sizes or highly compressible values), Comet's batch passes 2 GiB and Spark's does not.

The DELTA_LENGTH_BYTE_ARRAY decoder panics instead of returning that error (parquet 59.3.2 src/arrow/array_reader/byte_array.rs:514).

The epic lists the scan as honoring the batch size. It does, but in both cases the batch size alone doesn't bound the bytes.

Workaround

Lower spark.comet.batchSize.

Proposed fix

  • Keep dictionary-encoded byte columns as dictionaries out of the reader and unpack them after the scan in row ranges bounded by bytes, or cap scan batches by bytes.
  • At least, default the native scan's batch size to Spark's reader batch size.
  • Upstream: return an error from the DELTA_LENGTH_BYTE_ARRAY decoder instead of panicking.

Tests

A Parquet file with a flat dictionary-encoded string column, one 300 KB value repeated 8192 times, stays tiny on disk. Reading it with the native scan and comparing with Spark shows the problem, but needs about 2.5 GB of memory, so test the byte-bounded batching with a small budget injected for the test.

主要语言
Scala
星标
1.3k
派生
414
平均合并
3 天 5 小时
30 天内合并 PR
210

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/datafusion-comet 的其他 Issue

查看 apache/datafusion-comet 的全部 Issue

相似的 Issue

更多 Scala Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。