Repository navigation
fix(e6): rewrite date + -N * INTERVAL as date - N * INTERVAL - #335
Merged
Merged
Conversation
Postgres date + -N * INTERVAL was turned into DATE_ADD('DAY', -N * INTERVAL, date),
which the engine rejects (Cannot apply DATE_ADD to <VARCHAR>, <INTERVAL DAY>, <DATE>).
Emit date - N * INTERVAL instead and keep date + N * INTERVAL unchanged.
gauravdawar-e6
approved these changes
Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Samsung Tableau queries failed with
PARSING_FAILED(36 failures from 3 distinct queries on 3 Nov):Tableau sends
CURRENT_DATE + -2 * INTERVAL '1 DAY'. The Postgresdate + xrewrite inadd_sqlturned it intoDATE_ADD('DAY', -2 * INTERVAL '1 DAY', CURRENT_DATE), passing an interval where the engine expects a number.Fix
When the right side of
date + ...isN * INTERVAL:date + -N * INTERVAL->date - N * INTERVALdate + N * INTERVAL-> unchangedTesting
test_postgres_date_addition_to_date_add(tests/dialects/test_e6.py)make styleandmake testpassCURRENT_DATE - 2 * INTERVAL '1 DAY'returns today minus 2 days,CURRENT_DATE + 2 * INTERVAL '1 DAY'returns today plus 2 daysDATE_ADDin both Samsung and MULTIDIALECT modes