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

[SQL] CSE improvements - #7892

Merged
mihaibudiu merged 2 commits into
mainfrom
issue7597
Nov 8, 2026
Merged

mihaibudiu merged 2 commits into
mainfrom
issue7597

Conversation

@mihaibudiu

Copy link
Copy Markdown
Contributor

Linked Issue

Fixes #7597

Checklist

  • Unit tests added/updated

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
Fixes #7597

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
@mythical-fred-oss

Copy link
Copy Markdown
Contributor

What I ran: ./build.sh, then mvn test -pl SQL-compiler on EquivalenceTests, FuseExpensiveMapsTests, PersistentIdTests, MetadataTests and IncrementalConstantTests. All 98 tests passed, and so did the 3 QA tests I added below. I traced uses()/manyUsers and the borrow no-clone path by hand and found no correctness problems: &mut still clones, and block-local dependencies are still placed by lastDependency.

QA cases the PR's tests don't cover (all pass locally; worth adding):

Case Result
{ let a = f(t.0); let c = f(t.0); g(a, c) }, two lets with the same initializer 1 cell, resolves
Tup(f(&h(t.0)), h(t.0)), mixed borrowed and by-value use f(&(*t_1)) + (*t_1).clone(), exactly 1 clone
Tup(Tup(h(t.0)), Tup(h(t.0))), nested wrappers that are themselves equal 1 cell for h(t.0)
@Test
public void testCSEBorrowAndValue() {
    DBSPCompiler compiler = new DBSPCompiler(new CompilerOptions());
    DBSPVariablePath t = b.refVar(b.tup(b.i32()));
    DBSPExpression e = b.tuple(
            b.call("f", b.call(b.str(), "h", b.field(t, 0)).borrow()),
            b.call(b.str(), "h", b.field(t, 0)));
    IDBSPInnerNode result = cse(compiler, e.closure(t));
    assertCseVariables(compiler, result, 1);
    Assert.assertEquals(1, countClones(compiler, result));
}

Commit messages (medium): both commits are a subject line plus Signed-off-by. For a change to the CSE use-counting semantics, each body should say why: that wrappers previously hid repeated uses, and that blocks were not counted as users. That history is useful when this pass regresses later.

Otherwise LGTM: no feldera-pr-checks gate fails, and this is an internal compiler change that needs no docs or breaking-change handling.

@mihaibudiu
mihaibudiu added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 1696052 Nov 8, 2026
3 checks passed
@mihaibudiu
mihaibudiu deleted the issue7597 branch November 8, 2026 03:17
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] CSE for expressions can be improved

2 participants