Skip to content

[CALCITE-7681] SqlDatetimeSubtractionOperator drops parentheses around compound interval expressions - #5135

Open
matthewbayer wants to merge 1 commit into
apache:mainfrom
matthewbayer:calcite-datetime-interval-parentheses
Open

[CALCITE-7681] SqlDatetimeSubtractionOperator drops parentheses around compound interval expressions#5135
matthewbayer wants to merge 1 commit into
apache:mainfrom
matthewbayer:calcite-datetime-interval-parentheses

Conversation

@matthewbayer

@matthewbayer matthewbayer commented Jul 30, 2026

Copy link
Copy Markdown

Jira Link

CALCITE-7681

Changes Proposed

Apply the datetime operator's precedence when unparsing its operands. This preserves the compound interval in SQL such as:

CURRENT_DATE - (INTERVAL '3' YEAR + INTERVAL '3' YEAR)

Previously, RelToSql flattened the right operand and changed the expression's meaning:

CURRENT_DATE - INTERVAL '3' YEAR + INTERVAL '3' YEAR

Add regression coverage for the default and Spark dialects.

@sonarqubecloud

Copy link
Copy Markdown

@mihaibudiu

Copy link
Copy Markdown
Contributor

This is a draft, do you plan to submit this, or do you plan to close it?

@matthewbayer
matthewbayer marked this pull request as ready for review August 12, 2026 20:56
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.

3 participants