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

オープン
#27,328 コメント 0 件 リアクション 0 件 担当者 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時間
マージ済み PR(30日)
345

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/datafusion のほかの issue

apache/datafusion の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。