Offset overflow - Explode copies columns past 2 GiB and never splits one long row

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

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust, scala, spark

调研方向

Start in native/operators/src/explode.rs, especially next_chunk_rows at lines 320–342 and repeat_arrs_from_indices at lines 1291–1305; trace how output_lens feeds chunk sizing and take allocation. Add coverage using a small injected byte budget, including a single long-array row split across batches, and verify all output values and copied columns.

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

描述

area:expressions bug priority:medium

Part of #7267.

Problem

ExplodeExec copies every column that is not exploded once per array element, with take (repeat_arrs_from_indices, native/operators/src/explode.rs:1291-1305). It decides how many input rows to unnest at a time by output row count only (next_chunk_rows, :320-342), and it never splits one input row: a row whose array is longer than the batch size is built in one go and sliced afterwards.

So the copied columns can pass 2 GiB even when the input is small. In SELECT payload, explode(items) FROM t, rows with a 300 KB payload and 900 elements each are unnested nine at a time, so each chunk is 8,100 output rows holding 2.4 GB of payload. One row with a 1 MiB payload and a 2,100-element array overflows on its own, at any batch size. The query fails with Arrow error: Offset overflow error: 2147483648. Spark's GenerateExec produces one row at a time and succeeds.

The epic lists explode as honoring the batch size. It does for rows, but the copying makes each output row as large as its input row, so bytes per batch are not bounded.

A unit test on the one-row case fails with Offset overflow error: 2147483648 at batch_size=8192 and at batch_size=1024.

Line references are for main at 4e6b12290f.

Workaround

Lowering spark.comet.batchSize helps when many input rows share a chunk, but not for one row with a long array. spark.comet.exec.explode.enabled=false runs explode in Spark.

Proposed fix

  • When picking the next chunk, also bound the predicted output bytes: for each copied variable-width column, sum the value length times the row's output length (output_lens already holds the second factor) over the chunk's rows.
  • Let one input row be split across several output batches, by taking ranges of its repeated indices instead of the whole row at once.

Tests

take computes the output size before it allocates, so the one-row case above fails in milliseconds today. After the fix, test the chunking with a small byte budget injected for the test, and check that one row with a long array comes out in several batches with the right values.

主要语言
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 摘要。