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

[SQL] Improve Simplify for casts - #7929

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

mihaibudiu merged 1 commit into
mainfrom
issue7925

Conversation

@mihaibudiu

Copy link
Copy Markdown
Contributor

Linked Issue

Fixes #7925

Improved simplification code

Checklist

  • Unit tests added/updated

@mythical-fred-oss

Copy link
Copy Markdown
Contributor

LGTM. The fix covers #7925: Simplify no longer puts a SQL cast on a literal that only gains nullability (unary, binary, 1 * x).

What I ran

Check Result
./build.sh + Regression3Tests#issue7925 pass
ir.SimplifyTests, TestSimplifyConditionals, sql.simple.SimplifyTests, ReduceExpressionsTests 19/19 pass
CLI repro from the issue, plus variants: nested CASE with a NOT NULL branch, NOT, AND, b*1 INT, VARCHAR, TIMESTAMP all compile

Gates: tests added, no docs needed (bug fix), no deps or unsafe code, no flaky patterns.

missing (medium): The regression test only covers BOOLEAN. onlyAddsNullability excludes VARCHAR and now uses sameTypeIgnoringNullability. A compile-only case with INT/DECIMAL/VARCHAR columns in the same nested-CASE shape would pin that down cheaply. My CLI runs show they compile today.

pitfall (medium): See the inline comment. Non-literal nullability-only results still get a SqlUnsafe cast.

@mihaibudiu
mihaibudiu added this pull request to the merge queue Nov 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 11, 2026
Fixes #7925

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
@mihaibudiu mihaibudiu changed the title [SQL] Simplify folds a nullable cast of a literal into the literal [SQL] Improve Simplify for casts Nov 11, 2026
@mihaibudiu
mihaibudiu enabled auto-merge November 11, 2026 03:32
@mihaibudiu
mihaibudiu disabled auto-merge November 11, 2026 04:09
@mihaibudiu
mihaibudiu added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 483293d Nov 11, 2026
1 check passed
@mihaibudiu
mihaibudiu deleted the issue7925 branch November 11, 2026 05:27
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] SQL cast leftover ((b?)false): Simplify makes a SQL cast after ExpandCasts has run

2 participants