Skip to content

Spark, Databricks: parse multi-unit interval literals - #2616

Draft
moshap-firebolt wants to merge 2 commits into
apache:mainfrom
firebolt-analytics:moshap/upstream-interval-multi-units
Draft

moshap-firebolt wants to merge 2 commits into
apache:mainfrom
firebolt-analytics:moshap/upstream-interval-multi-units

Conversation

@moshap-firebolt

@moshap-firebolt moshap-firebolt commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #2614, whose commit this branch includes; only the last commit is new. It needs #2614 because the string form below has no unit, which Spark and Databricks reject until #2614 lands. I will rebase onto main once #2614 merges.

Spark's multi-units interval syntax lists several value / unit pairs, INTERVAL 10 YEAR 20 MONTH, documented as equivalent to INTERVAL '10 YEAR 20 MONTH'.

This adds Dialect::supports_interval_multi_units, enabled for SparkSqlDialect and DatabricksDialect. When set, parse_interval reads the extra pairs into that string form, so the AST is unchanged. A single unit, or a unit followed by something else (INTERVAL 3 DAY + 1), parses as before. Tests in sqlparser_common.rs cover dialects with and without the hook.

Spark's multi-units interval syntax lets the string carry its own
units, as in INTERVAL '1 YEAR 2 DAYS 3 HOURS', so no unit follows the
literal. Databricks Runtime parses with the same grammar. A unit after
a literal is still read; the expression form this gives up
(INTERVAL 1 + 1 DAY) is not Spark syntax.
@moshap-firebolt
moshap-firebolt marked this pull request as draft October 6, 2026 21:34
Spark's multi-units interval syntax lists several value / unit pairs,
INTERVAL 10 YEAR 20 MONTH, documented as the same as the string form
INTERVAL '10 YEAR 20 MONTH'. A new supports_interval_multi_units hook,
enabled for SparkSqlDialect and DatabricksDialect, reads the extra pairs
into that string form, so the AST is unchanged.
@moshap-firebolt
moshap-firebolt force-pushed the moshap/upstream-interval-multi-units branch from e3732a5 to f696fd3 Compare October 6, 2026 21:35
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.16%. Comparing base (14cbf75) to head (f696fd3).

Files with missing lines Patch % Lines
src/parser/mod.rs 90.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2616      +/-   ##
==========================================
+ Coverage   81.14%   81.16%   +0.01%     
==========================================
  Files          42       42              
  Lines       33736    33766      +30     
  Branches    33736    33766      +30     
==========================================
+ Hits        27376    27407      +31     
+ Misses       2797     2795       -2     
- Partials     3563     3564       +1     

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants