Scalar subquery in a VALUES row fails with "Internal error: ScalarSubqueryExpr evaluated before the subquery was executed"

未關閉
#27,328 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@v28k 已經在處理了。

開始於 2026年11月11日。

  • #27329 來自 @v28k —— 未關閉

評估

難度
4/5
預估耗時
3-5 天
新手友好度
25/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
停滯
技術堆疊
rust, sql
領域
databases

研究方向

Start by reading LogicalPlan::Values and MemorySourceConfig::try_new_as_values, then trace how ScalarSubqueryExpr is evaluated by ScalarSubqueryExec. Add regression coverage for the three SQL examples, including the expected (1, 5) result and inserted row. A linked pull request is already open, so this work is underway.

由索引模型根據 Issue 內容生成。

描述

bug
Describe the bug

A VALUES clause whose rows contain an uncorrelated scalar subquery fails during physical planning with an internal error:

Internal error: ScalarSubqueryExpr evaluated before the subquery was executed. This issue was likely caused by a bug in DataFusion's code.

LogicalPlan::Values is processed by MemorySourceConfig::try_new_as_values, which attempts to evaluate every row expression while the physical plan is built. Under physical scalar subquery execution, an uncorrelated scalar subquery is represented as a ScalarSubqueryExpr, which expects execution-time evaluation inside ScalarSubqueryExec. Because the subquery has not yet run at planning time, evaluation fails with an internal error.

To Reproduce

VALUES ((SELECT 1), 5);
SELECT * FROM (VALUES ((SELECT min(x) FROM (VALUES (1), (2)) AS v(x)), 5)) AS t(a, b);
CREATE TABLE v (a BIGINT, b BIGINT);
INSERT INTO v VALUES ((SELECT 1), 5);

Expected behavior

The first two SELECT queries should return (1, 5). The INSERT statement should insert one row (1, 5) into table v.

Additional context

Reproduced on main at commit bc86321 (57.0.0-dev) and with datafusion-python 55.0.0. Found using an automated grammar-based SQL fuzzer.

Willingness to contribute

I plan to contribute a fix for this bug independently

主要語言
Rust
星號
9.6k
分支
2.6k
平均合併
3 天 4 小時
30 天內合併 PR
345

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

apache/datafusion 的其他 Issue

查看 apache/datafusion 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。