Repository navigation
fix: parse interval parenthesized modulo (Fixes #24235) - #24242
Merged
mergify[bot] merged 4 commits intoMay 7, 2026
Merged
mergify[bot] merged 4 commits into
mergify[bot] merged 4 commits into
Conversation
Normalize INTERVAL (expr) % n forms to the existing unary-plus parse path so DATE_ADD and DATE_SUB can accept modulo arithmetic before the time unit. Add parser coverage for issue matrixorigin#24235 examples. Fixes matrixorigin#24235 Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Fixes MySQL dialect parsing for DATE_ADD/DATE_SUB ... INTERVAL (expr) % n <unit> by normalizing that specific shape into an equivalent unary-plus form that the existing grammar already accepts.
Changes:
- Preprocesses SQL input to rewrite
INTERVAL (expr) % ...intoINTERVAL +(expr) % ...while skipping strings/backticks/comments. - Applies the normalization in both
MySQLParser.ParseandNewLexercode paths. - Adds regression tests covering the failing queries and the normalization behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/sql/parsers/dialect/mysql/mysql_lexer.go | Adds SQL normalization pass and helper scanners to support parenthesized modulo in INTERVAL operands. |
| pkg/sql/parsers/dialect/mysql/interval_issue24235_test.go | Adds regression tests for issue #24235 and unit test for normalization behavior. |
Add the repository license header required by SCA for the issue matrixorigin#24235 parser coverage test. Co-authored-by: Copilot <[email protected]>
LeftHandCold
requested review from
ouyuanning
and removed request for
ouyuanning
April 29, 2026 09:08
XuPeng-SH
approved these changes
May 7, 2026
Contributor
Merge Queue Status
This pull request spent 53 minutes 53 seconds in the queue, including 53 minutes 36 seconds running CI. Required conditions to merge
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
fixes #24235
What this PR does / why we need it:
Allows DATE_ADD/DATE_SUB interval operands to contain parenthesized modulo arithmetic before the time unit, such as:
The existing grammar already accepts the equivalent unary-plus expression form, so this PR narrowly normalizes
INTERVAL (expr) % ...to that existing parse path without increasing yacc conflicts. It also keeps string/comment contents unchanged during normalization.Validation
go test ./pkg/sql/parsers/dialect/mysql -count=1