Skip to content

MySQL: Support compound time units in EXTRACT and INTERVAL - #2700

Open
princejain756 wants to merge 1 commit into
apache:mainfrom
princejain756:mysql-compound-datetime-units
Open

princejain756 wants to merge 1 commit into
apache:mainfrom
princejain756:mysql-compound-datetime-units

Conversation

@princejain756

@princejain756 princejain756 commented Oct 21, 2026 •

Copy link
Copy Markdown

MySQL and MariaDB accept 11 compound time units in EXTRACT(unit FROM expr) and INTERVAL expr unit expressions (SECOND_MICROSECOND, MINUTE_MICROSECOND, MINUTE_SECOND, HOUR_MICROSECOND, HOUR_SECOND, HOUR_MINUTE, DAY_MICROSECOND, DAY_SECOND, DAY_MINUTE, DAY_HOUR, YEAR_MONTH), which previously failed with Expected: date/time field or INTERVAL requires a unit after the literal value:

This change adds the 11 compound unit keywords and DateTimeField variants and recognizes them in Parser::parse_date_time_field and Parser::next_token_is_temporal_unit, gated by a new Dialect::supports_compound_date_time_fields so other dialects keep treating the words as custom fields or rejecting them.

Closes #2693

Dialects: MySQL, MariaDB

This PR was implemented with AI assistance.

@github-actions github-actions Bot added the MySQL label Oct 21, 2026
@LucaCappelletti94 LucaCappelletti94 added the enhancement New feature or request label Oct 21, 2026
@princejain756
princejain756 force-pushed the mysql-compound-datetime-units branch from 96f4701 to 56c476d Compare October 21, 2026 21:55
@alamb alamb added the Prolific Author author has opened PRs in many repositories in the last month label Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request MySQL Prolific Author author has opened PRs in many repositories in the last month

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MySQL: compound time units (YEAR_MONTH, DAY_HOUR...) fail in EXTRACT and INTERVAL

3 participants