← 输入框|github.com|刷新
Skip to content

[SQL] Remove subqueries exposed by the removal of other subqueries - #7927

Merged
mihaibudiu merged 1 commit into
mainfrom
issue7918
Nov 11, 2026
Merged

mihaibudiu merged 1 commit into
mainfrom
issue7918

Conversation

@mihaibudiu

Copy link
Copy Markdown
Contributor

Linked Issue

Fixes #7918

Checklist

  • Unit tests added/updated

@mythical-fred-oss

Copy link
Copy Markdown
Contributor

What I ran: ./build.sh, then mvn test -Dtest=Regression3Tests,SubQueryTests,RowComparisonTests,CteToLocalViewsTests.

Suite Result
Regression3Tests (45, with the PR's 5 new tests plus 4 QA tests of mine) ✅
SubQueryTests, RowComparisonTests ✅
CteToLocalViewsTests ❌ testRetryRequested fails. It passes on base; see the inline comment
  • bug (high), gate "Unit Tests": CI will be red until testRetryRequested gets a query that still needs the CTE retry. Without one, the fallback path has no test.
  • QA tests I added (all pass, not in the PR): these cover three levels of nesting, a Project subquery inside a Project subquery, a HAVING IN inside a SELECT-list subquery, and nested correlated EXISTS. Consider adding them:
CREATE VIEW V AS SELECT x,
  EXISTS(SELECT 1 FROM s WHERE x IN (SELECT y FROM t WHERE y IN (SELECT x FROM s))) AS e FROM s;
CREATE VIEW V AS SELECT x, (SELECT MAX((SELECT COUNT(*) FROM t)) FROM s) AS c FROM s;
CREATE VIEW V AS SELECT x,
  (SELECT COUNT(*) FROM (SELECT x FROM s GROUP BY x HAVING x IN (SELECT y FROM t))) AS c FROM s;
CREATE VIEW V AS SELECT x, EXISTS(SELECT 1 FROM t WHERE t.y = s.x
  AND EXISTS(SELECT 1 FROM t AS t2 WHERE t2.y = s.x + 1)) AS e FROM s;
  • Commit message: the body is only Fixes #7918. Please add a sentence on why: the sequential HEP rules ran once each, so a subquery exposed by a later rule was never removed.

The subquery-removal rules ran as separate HEP instructions, once each, in the
order FILTER, PROJECT, JOIN, so a subquery that a later rule exposed was not
removed. The rules now run together as one rule collection.

Fixes #7918

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
@mihaibudiu
mihaibudiu added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 4db1724 Nov 11, 2026
1 check passed
@mihaibudiu
mihaibudiu deleted the issue7918 branch November 11, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SQL] Program with subquery crashes the compiler

2 participants