Skip to content

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

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

[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

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