Skip to content

MySQL: Fix zero-value YEAR decoding, improve user docs around zero-value date/time types#36649

Open
martykulma wants to merge 4 commits into
MaterializeInc:mainfrom
martykulma:maz-mysql-zero-val-updates
Open

MySQL: Fix zero-value YEAR decoding, improve user docs around zero-value date/time types#36649
martykulma wants to merge 4 commits into
MaterializeInc:mainfrom
martykulma:maz-mysql-zero-val-updates

Conversation

@martykulma
Copy link
Copy Markdown
Contributor

@martykulma martykulma commented May 20, 2026

This started doc change and new test, but then @kay-kim uncovered a bug via manual testing! No we have a fix, which is included.

This PR fixes handling of zero-value YEAR

  • snapshot decodes this as "0" instead of "0000"
  • binlog decodes this as "1900" instead of "0000"

This also works around a mysql_common bug that treat zero-year binlog as 1900, which is an invalid year. It should be 0. See MySQL crazy set of rules for YEAR.

Additionally:

  • adds some clarification to Materialize documentation around the integration with MySQL when using zero-value DATE, DATETIME, TIMESTAMP, and YEAR.
  • expands the test coverage for YEAR to verify the documented behavior
  • adjusts tests for DATE/DATETIME/TIMESTAMP to ensure snapshot and steady state paths are tested

@martykulma martykulma marked this pull request as ready for review May 21, 2026 18:47
@martykulma martykulma requested a review from a team as a code owner May 21, 2026 18:47
@martykulma martykulma requested a review from a team May 21, 2026 18:49
Comment thread doc/user/data/mysql_source_details.yml Outdated
Comment thread test/mysql-cdc/text-columns-year.td Outdated
4 "1901"
5 "2155"
6 "2025"
7 "0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 1900?

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for running it! It should definitely be 0, and the reason the automated test didn't catch it is because it ran so fast, everything was read via the snapshot. I modified the test and now see the failure.

text-columns-year.td:76:1: error: non-matching rows: expected:
[["1", "2024"], ["10", "2155"], ["2", "0"], ["3", "<null>"], ["4", "1901"], ["5", "2155"], ["6", "2025"], ["7", "0"], ["8", "<null>"], ["9", "1901"]]
got:
[["1", "2024"], ["10", "2155"], ["2", "0"], ["3", "<null>"], ["4", "1901"], ["5", "2155"], ["6", "2025"], ["7", "1900"], ["8", "<null>"], ["9", "1901"]]
Poor diff:
- 7 0
+ 7 1900

@martykulma martykulma force-pushed the maz-mysql-zero-val-updates branch from 86f9075 to cbbdf7a Compare May 21, 2026 22:26
@martykulma martykulma requested a review from a team as a code owner May 21, 2026 22:26
@martykulma martykulma changed the title MySQL: Additional documentation and test around zero-value date / time MySQL: Fix zero-value YEAR decoding, improve user docs around zero-value date/time types May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants