You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: WEEK(date, mode) two-argument form rejected with 'bad value [DATE BIGINT]' #24236
Others: discovered via NL2SQL workload generating standard MySQL syntax
Actual Behavior
Calling WEEK(date, mode) with the standard 2-argument form fails at runtime with an "invalid argument" error reporting the type combination [DATE BIGINT] is not accepted.
ERROR 20203 (HY000): invalid argument function week, bad value [DATE BIGINT]
Expected Behavior
MySQL WEEK(date, mode) is a standard 2-argument function where:
date is a DATE / DATETIME
mode is an integer 0..7 controlling the week-numbering semantics (whether week starts on Sunday/Monday, whether it's an ISO week, etc.)
It should accept an integer literal (parsed as BIGINT) for the mode argument and either auto-cast to the expected smaller integer type or document/permit the BIGINT path.
-- 1-arg form works:SELECT WEEK(CURRENT_DATE);
-- 2-arg form fails with error 20203:SELECT WEEK(CURRENT_DATE, 3);
SELECT WEEK(CURRENT_DATE, 0);
SELECT WEEK('2026-04-20', 3);
Additional information
The error string bad value [DATE BIGINT] suggests MatrixOne's WEEK only registers a signature for one argument type (or for (DATE, smaller-int)) and the integer literal 3 is being typed as BIGINT without an implicit conversion path.
Suggested fix paths:
Register a WEEK(DATE, INT64) signature; or
Add an implicit BIGINT → smaller-int cast for mode; or
Treat literal integers in this argument position as a constrained type.
This is one of three related issues filed from the same NL2SQL session that produced typical "this week vs last week" SQL. The other two are:
YEARWEEK function not supported (preferred cleanest form)
Parser error on arithmetic expression inside INTERVAL clause (fallback path also broken)
The combined effect is that agents (and human users) writing standard MySQL week-aligned comparisons have no working idiom available in v3.0.9.
Activity
fix: WEEK() function mode parameter support (Fixes matrixorigin#24236)
fix: WEEK() function mode parameter support (Fixes matrixorigin#24236)
fix: WEEK() function mode parameter support (Fixes #24236) (#24239)
Ariznawlll commentedon May 7, 2026
验证结果
已验证
WEEK(date, mode)双参数形式在当前 main 分支上可正常工作,所有 mode 0~7 结果与 MySQL 完全对齐。测试环境
mysql -h 127.0.0.1 -P 6001 -udump -p111mysql -u root -pweilu0220验证内容
所有结果与 MySQL 一致。已提交 BVT case(93 条用例,100% 通过):
test/distributed/cases/function/func_datetime_week.test遗留问题
WEEK(date)单参数形式未正确读取@@default_week_format(MO 返回 19 即 mode=1 行为,MySQL 返回 18 即 mode=0),已单独提 issue。test(bvt): add WEEK and YEARWEEK function test cases (#24295)