Skip to content

PostgreSQL: Parse a word after an interval value that is not a PostgreSQL field as an alias - #2775

Merged
LucaCappelletti94 merged 1 commit into
mainfrom
upstream/postgres-interval-qualifier
Oct 30, 2026
Merged

LucaCappelletti94 merged 1 commit into
mainfrom
upstream/postgres-interval-qualifier

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

SELECT interval '1' week parses as a one-week interval under PostgreSqlDialect, but PostgreSQL (VERY COUNTERINTUITIVELY) returns one second in a column named week. Its grammar (opt_interval in gram.y) takes only YEAR, MONTH, DAY, HOUR, MINUTE and SECOND and their TO ranges as an interval qualifier, so any other word after the value is a column alias. The same holds for decade, quarter, epoch and plural spellings such as days.

The words that can start a qualifier move from Parser::next_token_is_temporal_unit into a new Dialect::is_interval_qualifier, with the existing list as the default and PostgreSQL's six fields as its override. Other dialects parse as before.

@LucaCappelletti94 LucaCappelletti94 added bug Something isn't working PostgreSQL labels Oct 30, 2026
@codecov-commenter

codecov-commenter commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.59%. Comparing base (e7c4410) to head (2fa1622).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2775   +/-   ##
=======================================
  Coverage   82.59%   82.59%           
=======================================
  Files          42       42           
  Lines       35575    35582    +7     
  Branches    35575    35582    +7     
=======================================
+ Hits        29382    29389    +7     
  Misses       2659     2659           
  Partials     3534     3534           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/postgres-interval-qualifier branch 2 times, most recently from 4c51d18 to 4c65936 Compare October 30, 2026 14:30
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/postgres-interval-qualifier branch from 4c65936 to 2fa1622 Compare October 30, 2026 17:41
@LucaCappelletti94

Copy link
Copy Markdown
Contributor Author

Thanks @sabir-akhadov-localstack for the review, I will merging this now.

cc @alamb

@LucaCappelletti94
LucaCappelletti94 added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 1e0bc45 Oct 30, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PostgreSQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants