fix: WEEK() function mode parameter support (Fixes #24236)#24239
Merged
mergify[bot] merged 4 commits intomatrixorigin:3.0-devfrom May 6, 2026
Merged
fix: WEEK() function mode parameter support (Fixes #24236)#24239mergify[bot] merged 4 commits intomatrixorigin:3.0-devfrom
mergify[bot] merged 4 commits intomatrixorigin:3.0-devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR broadens MySQL-compatibility in the SQL layer by adding WEEK(date, mode) overloads and also introducing several additional MySQL behaviors (null-safe <=>, JSON ->/->> operators, JSON→numeric casts, and multi-table DROP TABLE) spanning parser, planner, compiler, and frontend privilege handling.
Changes:
- Add
WEEK(date|datetime, int64 mode)overloads and update week computation to accept a mode argument. - Implement MySQL operators/features: null-safe equal
<=>, JSON->/->>parsing, and JSON→numeric casting behavior. - Add support for multi-table
DROP TABLEthrough plan/proto, planning, compilation, and privilege extraction/auth checks, plus distributed test coverage.
Reviewed changes
Copilot reviewed 32 out of 34 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/distributed/cases/join/apply.result | Updates expected results now that JSON can be compared/cast to numeric. |
| test/distributed/cases/function/func_null_safe_equal.sql | Adds distributed SQL coverage for <=> semantics. |
| test/distributed/cases/function/func_null_safe_equal.result | Expected outputs for <=> distributed tests. |
| test/distributed/cases/function/func_json_arrow.sql | Adds distributed SQL coverage for JSON -> / ->> operators. |
| test/distributed/cases/function/func_json_arrow.result | Expected outputs for JSON arrow operator tests. |
| test/distributed/cases/ddl/drop_table_multiple.sql | Adds distributed coverage for multi-table DROP TABLE behavior. |
| test/distributed/cases/ddl/drop_table_multiple.result | Expected outputs for multi-table DROP TABLE tests. |
| proto/plan.proto | Extends DropTable plan message with per-table entries for multi-drop. |
| pkg/sql/plan/function/list_operator.go | Registers <=> operator and its type-checking/cast behavior. |
| pkg/sql/plan/function/list_builtIn.go | Registers 2-arg WEEK() overloads for `(date |
| pkg/sql/plan/function/init.go | Adds encoded ID/name constants for <=>. |
| pkg/sql/plan/function/function_id_test.go | Updates function-id registry expectations for new <=> id. |
| pkg/sql/plan/function/function_id.go | Adds NULL_SAFE_EQUAL function id and registers <=> name. |
| pkg/sql/plan/function/func_unary.go | Reworks DateToWeek / DatetimeToWeek to accept an optional mode. |
| pkg/sql/plan/function/func_compare_test.go | Adds unit tests for numeric comparisons and <=> edge cases. |
| pkg/sql/plan/function/func_compare_fix.go | Rewrites numeric type-mismatch comparison fallback (exact/approx paths). |
| pkg/sql/plan/function/func_compare.go | Implements <=> execution and updates mismatch-compare callsites. |
| pkg/sql/plan/function/func_cast_test.go | Adds unit tests for JSON→numeric casting semantics (precision/overflow/null). |
| pkg/sql/plan/function/func_cast.go | Enables JSON→numeric casts and implements conversion logic. |
| pkg/sql/plan/deepcopy.go | Adds deep-copy support for recursive multi-drop DropTable plans. |
| pkg/sql/plan/build_expr_test.go | Adds plan-binding tests for tuple <=> behavior. |
| pkg/sql/plan/build_ddl_test.go | Adds tests for FK-related drop-target logic in multi-drop. |
| pkg/sql/plan/build_ddl.go | Implements multi-table DROP TABLE planning and FK-target checking. |
| pkg/sql/plan/build_alter_table_test.go | Adds tests asserting JSON→numeric remains blocked for DDL type changes. |
| pkg/sql/plan/build_alter_modify_column.go | Blocks JSON→numeric type changes in DDL while allowing runtime casts. |
| pkg/sql/plan/base_binder.go | Adds binder support for <=> including tuple expansion to AND of <=>. |
| pkg/sql/parsers/dialect/mysql/scanner.go | Adds tokenization for ->> (LONG_ARROW). |
| pkg/sql/parsers/dialect/mysql/mysql_sql_test.go | Adds SQL pretty-print tests for -> / ->> rewrites. |
| pkg/sql/parsers/dialect/mysql/mysql_sql.y | Adds grammar rules translating ->/->> into json_extract / json_unquote(json_extract). |
| pkg/sql/compile/ddl.go | Executes multi-drop by iterating per-table entries and adds warning-on-missing-child-table path. |
| pkg/frontend/authenticate_test.go | Adds privilege/ownership tests for multi-table DROP TABLE and plan tip extraction. |
| pkg/frontend/authenticate.go | Updates privilege tip extraction and privilege/ownership checks for multi-drop. |
0c689b3 to
bf93e18
Compare
Exercise WEEK through registered overloads and cover NULL/select-list branches for the two-argument mode implementation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ouyuanning
approved these changes
Apr 29, 2026
aunjgr
approved these changes
Apr 29, 2026
XuPeng-SH
approved these changes
May 6, 2026
Contributor
Merge Queue Status
This pull request spent 1 hour 41 minutes 42 seconds in the queue, including 53 minutes 1 second running CI. Required conditions to merge
|
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 #24236
What this PR does / why we need it:
Re-implements WEEK() mode parameter support from main on 3.0-dev while preserving existing one-argument WEEK behavior.
MySQL's
WEEK(date, mode)accepts an integer 0-7 as second argument to control week numbering semantics. Previously, MatrixOne's WEEK only registered single-argument overloads, causingWEEK(date, 3)to fail with "invalid argument function week, bad value [DATE BIGINT]".This PR:
WEEK(date)/WEEK(datetime)result path used by existing BVT cases(T_date, T_int64)and(T_datetime, T_int64)overloads2000-01-01default WEEK case that failed BVTValidation
go test ./pkg/sql/plan/function -count=1