Skip to content

repr: Honor DateStyle MDY and two-digit-year windowing in date parsing#37838

Merged
def- merged 1 commit into
MaterializeInc:mainfrom
def-:pr-sql-461
Jul 24, 2026
Merged

repr: Honor DateStyle MDY and two-digit-year windowing in date parsing#37838
def- merged 1 commit into
MaterializeInc:mainfrom
def-:pr-sql-461

Conversation

@def-

@def- def- commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Interpret separated all-numeric date literals the way PostgreSQL does under the pinned DateStyle 'ISO, MDY': a one- or two-digit leading field starts a month-day-year date, and a two-digit year is windowed into 1970..=2069. A leading field of three or more digits keeps the year-month-day interpretation. This applies to date, timestamp and timestamptz parsing at the SQL layer.

  SELECT date '01/02/03';  -- now 2003-01-02, was 0001-02-03
  SELECT date '99-01-08';  -- now an error (month 99), was 0099-01-08

Storage source casts stay on new frozen legacy parse functions (parse_date_legacy and friends) so their evaluation is unchanged, per the stability contract in mz_storage_types::sources::casts.

Closes: SQL-461

@def-
def- requested review from a team as code owners July 23, 2026 17:54
@def-
def- requested a review from SangJunBak July 24, 2026 06:28
Interpret separated all-numeric date literals the way PostgreSQL does
under the pinned DateStyle 'ISO, MDY': a one- or two-digit leading
field starts a month-day-year date, and a two-digit year is windowed
into 1970..=2069. A leading field of three or more digits keeps the
year-month-day interpretation. This applies to date, timestamp and
timestamptz parsing at the SQL layer.

    SELECT date '01/02/03';  -- now 2003-01-02, was 0001-02-03
    SELECT date '99-01-08';  -- now an error (month 99), was 0099-01-08

Storage source casts stay on new frozen legacy parse functions
(parse_date_legacy and friends) so their evaluation is unchanged, per
the stability contract in mz_storage_types::sources::casts.

Closes: SQL-461

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@def-
def- merged commit 669b67e into MaterializeInc:main Jul 24, 2026
124 checks passed
@def-
def- deleted the pr-sql-461 branch July 24, 2026 09:07
def- added a commit to def-/materialize that referenced this pull request Jul 24, 2026
@def- def- mentioned this pull request Jul 24, 2026
def- added a commit to def-/materialize that referenced this pull request Jul 24, 2026
def- added a commit to def-/materialize that referenced this pull request Jul 24, 2026
MaterializeInc#37838)

Interpret separated all-numeric date literals the way PostgreSQL does
under the pinned DateStyle 'ISO, MDY': a one- or two-digit leading field
starts a month-day-year date, and a two-digit year is windowed into
1970..=2069. A leading field of three or more digits keeps the
year-month-day interpretation. This applies to date, timestamp and
timestamptz parsing at the SQL layer.

      SELECT date '01/02/03';  -- now 2003-01-02, was 0001-02-03
SELECT date '99-01-08'; -- now an error (month 99), was 0099-01-08

Storage source casts stay on new frozen legacy parse functions
(parse_date_legacy and friends) so their evaluation is unchanged, per
the stability contract in mz_storage_types::sources::casts.

Closes: SQL-461

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
def- added a commit to def-/materialize that referenced this pull request Jul 24, 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