Skip to content

fix(plan): allow parenthesized uuid default on string columns#24795

Merged
mergify[bot] merged 8 commits into
matrixorigin:mainfrom
VioletQwQ-0:violet/issue-24734
Jun 5, 2026
Merged

fix(plan): allow parenthesized uuid default on string columns#24795
mergify[bot] merged 8 commits into
matrixorigin:mainfrom
VioletQwQ-0:violet/issue-24734

Conversation

@VioletQwQ-0
Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #24734

What this PR does / why we need it:

Allows explicit parenthesized expression defaults such as DEFAULT (uuid()) on string columns, while preserving the existing UUID-type guard for bare DEFAULT uuid().

Changes:

  • Detect parenthesized default expressions before applying the bare uuid() type guard.
  • Bind the inner expression for generated default values while preserving the original default string.
  • Add unit and BVT regression coverage for varchar NOT NULL DEFAULT (uuid()).

Validation:

  • go test ./pkg/sql/plan -run 'TestBuildDefaultExprAllowsParenthesizedUuidForStringDefault|TestBuildDefaultExprKeepsBareUuidTypeGuard' -count=1
  • git diff --check
  • BVT not run locally; covered by CI.

@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/bug Something isn't working label Jun 3, 2026
@VioletQwQ-0 VioletQwQ-0 marked this pull request as draft June 3, 2026 03:26
@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Jun 3, 2026
@VioletQwQ-0 VioletQwQ-0 marked this pull request as ready for review June 3, 2026 07:13
@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Copy link
Copy Markdown
Contributor

@XuPeng-SH XuPeng-SH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking correctness issue:

The new ParenExpr handling unwraps parentheses only after the existing special-case NULL checks. That breaks the long-standing semantics that DEFAULT (NULL) should be equivalent to DEFAULT NULL.

In pkg/sql/plan/build_util.go, the JSON / GEOMETRY / NOT NULL guards still call isNullAstExpr(expr) before the new:

if paren, ok := expr.(*tree.ParenExpr); ok {
    isExpressionDefault = true
    expr = paren.Expr
}

But isNullAstExpr() only recognizes a raw *tree.NumVal null literal. So DEFAULT (NULL) no longer hits those earlier NULL checks.

That creates real semantic regressions, for example:

  • NOT NULL DEFAULT (NULL) can bypass the existing invalid-null-default guard.
  • Types that explicitly allow only DEFAULT NULL here (such as JSON / GEOMETRY) will treat (NULL) as a non-NULL expression instead.

Please normalize/unwrap parenthesized expressions before the NULL-specific checks as well, while still preserving the original AST separately for OriginString.

Copy link
Copy Markdown
Contributor

@XuPeng-SH XuPeng-SH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest head fixes the earlier blocker around DEFAULT (NULL) by normalizing parenthesized expressions before the NULL-specific checks while still preserving the original default string. I did not find another blocking issue in the parenthesized DEFAULT (uuid()) handling on string columns.

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jun 5, 2026

Merge Queue Status

  • Entered queue2026-06-05 11:06 UTC · Rule: main
  • Checks passed · in-place
  • Merged2026-06-05 12:09 UTC · at 87e63d987f210e8a82a3e3f48f7436ecb629bd7f · squash

This pull request spent 1 hour 3 minutes 39 seconds in the queue, including 1 hour 2 minutes 43 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-skipped = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants