Skip to content

[Bug]: CAST zero datetime string errors instead of returning NULL like MySQL #25253

Closed

Description

@Ariznawlll

Bug Report

MatrixOne Version

Latest origin/main verified locally at 33e96877604ad4b847ea7d5c55eb09429de1a5b6.

Reproduce Steps

select cast('0000-00-00' as date),
       cast('0000-00-00 00:00:00' as datetime),
       cast('00:00:00' as time);

Expected Behavior

MySQL returns:

NULL    NULL    00:00:00

Actual Behavior

MatrixOne matches the date and time rows individually, but errors on the zero datetime row:

select cast('0000-00-00' as date);              -- NULL
select cast('0000-00-00 00:00:00' as datetime); -- ERROR 20301: invalid datetime value 0000-00-00 00:00:00
select cast('00:00:00' as time);                -- 00:00:00

Notes

Found during expression-only Batch A cast matrix exploration. The matching zero date/time rows were added to BVT; the zero datetime row was excluded.

Activity

  1. added
    kind/bug
    severity/s1
    on Jun 30, 2026
  2. added this to the MO-202607 milestone on Jul 1, 2026
  3. added theissue type on Jul 1, 2026
  4. added
    ai-light
    on Jul 1, 2026
  5. daviszhen commented on Jul 3, 2026

    @daviszhen
    Contributor

    建议保持 mo的行为.

    the range for DATETIME values is '1000-01-01 00:00:00.000000' to '9999-12-31 23:59:59.499999'

    pg也是报错

    Image
  6. added
    severity/s0
    and removed
    severity/s1
    on Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-lightkind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions