Scalar subquery in a VALUES row fails with "Internal error: ScalarSubqueryExpr evaluated before the subquery was executed"
維護者通常 1 天內回覆
評估
研究方向
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 內容生成。
描述
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
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
apache/datafusion 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
apache/datafusion#27315 · 2 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
apache/datafusion#27094 · 1 則留言 ·
維護者通常 1 天內回覆
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yaml可能已有人在做 @jonasHanhan 於 9 天前認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 76/100
apache/datafusion#27059 ·
維護者通常 1 天內回覆
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column stats可能已有人在做 @joseph-isaacs 於 10 天前認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 72/100
apache/datafusion#27050 ·
維護者通常 1 天內回覆
-
physical-plan: decoding an Unnest or Explain node with an unset field panics可能已有人在做 @geoHeil 於 9 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
apache/datafusion#26999 · 1 則留言 ·
維護者通常 1 天內回覆
查看 apache/datafusion 的全部 Issue
相似的 Issue
-
P3
難度 2/5 1-3 小時 新手友好度 70/100
HerringtonDarkholme/hd-lang#1770 ·
維護者通常 1 天內回覆
-
needs triage
難度 2/5 1-3 小時 新手友好度 85/100
pbakaus/impeccable#1436 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
jonathanong/no-mistakes#3332 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
swc-project/swc-next-issues#310 ·
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
swc-project/swc-ai-issues#653 ·