Skip to content

[Bug]: WEEK(date, mode) two-argument form rejected with 'bad value [DATE BIGINT]' #24236

@dengn

Description

@dengn

Branch Name

main (v3.0.9 release tag)

Commit ID

39cfa47

Other Environment Information

  • Hardware parameters: n/a (release build)
  • OS type: n/a
  • 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.

Reference: https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_week

Steps to Reproduce

-- 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:

  1. Register a WEEK(DATE, INT64) signature; or
  2. Add an implicit BIGINT → smaller-int cast for mode; or
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions