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

[SQL] Fix persistent ID collision - #7848

Merged
mihaibudiu merged 3 commits into
mainfrom
issue7832
Nov 5, 2026
Merged

mihaibudiu merged 3 commits into
mainfrom
issue7832

Conversation

@mihaibudiu

Copy link
Copy Markdown
Contributor

Linked Issue

Fixes #7832

Collisions happen when internal representations that are not equivalent generate Rust code that is identical.
This PR fixes collisions for Some() expressions and literals by switching to a "canonical" representation.

Checklist

  • Unit tests added/updated

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

Copy link
Copy Markdown
Contributor

What I ran: ./build.sh, then mvn test -Dtest=PersistentIdTests,ShareIndexesTests,IncrementalRegressionTests (107/107 pass), plus SimplifyTests,TimeArithmeticTests,DateArithmeticTests,StructTests,SerializationTests,InternTests,WindowTests (68/68 pass). On the base commit, someOfLiteral and both issue7832 tests fail as expected. The two intervalUnits* tests already pass on main, so they only cover the new equivalent() rule, not an existing bug.

bug (high), regression: the stricter literal equivalent() reintroduces duplicate persistent ids for interval literals that NormalizeLiterals doesn't reach (-INTERVAL 60 MINUTES vs -INTERVAL 1 HOUR). Repro is in the inline comment. That query compiles on main and crashes on this branch, so the change needs a fix before merge.

missing (medium), tests:

Case Status
Runtime check that normalized interval comparisons keep their results ((ts-ts2) MINUTE > INTERVAL 60 MINUTE / > INTERVAL 1 HOUR, DAY TO SECOND) I wrote it and it passes. Worth adding, since all the PR's interval tests are compile-only
Interval literals under NEG, CASE, IN, BETWEEN, TIMESTAMPADD in two views NEG crashes. The others pass
DBSPLiteral.equivalent with same value, different type (e.g. DECIMAL scale) Not covered

Suggested runtime test (passes on this branch):

@Test
public void intervalUnitsRuntime() {
    var ccs = this.getCCS("""
            CREATE TABLE t (ts TIMESTAMP NOT NULL, ts2 TIMESTAMP NOT NULL);
            CREATE VIEW v AS SELECT (ts - ts2) MINUTE > INTERVAL 60 MINUTE AS a,
                (ts - ts2) MINUTE > INTERVAL 1 HOUR AS b,
                (ts - ts2) SECOND <= INTERVAL '0 01:00:30' DAY TO SECOND AS c,
                ts2 + INTERVAL 1 HOUR = ts AS d
            FROM t;""");
    ccs.step("INSERT INTO t VALUES('2024-01-01 01:00:30', '2024-01-01 00:00:00'), ('2024-01-01 01:01:00', '2024-01-01 00:00:00');", """
             a | b | c | d | weight
            ------------------------
             false | false | true | false | 1
             true | true | false | false | 1""");
}

Commits: the bodies contain only Signed-off-by and don't say why the change was made. One subject is longer than 72 characters and gets truncated.

…rval literals

equivalent() of literals and of array, map, variant and geo point constructors
also compares the types.

An interval literal has a comment with its SQL type, e.g.,
/*INTERVAL MINUTE*/, unless its unit is the largest unit that divides the value.

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
@mihaibudiu
mihaibudiu added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 6eae6cf Nov 5, 2026
1 check passed
@mihaibudiu
mihaibudiu deleted the issue7832 branch November 5, 2026 06:53
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] Two MapIndex operators get the same persistent id: CSE does not see that Some(tuple) and a nullable tuple are equal

2 participants