feat(spark, databricks)!: Support for DATE_ADD functions#3609
Merged
georgesittas merged 3 commits intomainfrom Jun 7, 2024
Merged
feat(spark, databricks)!: Support for DATE_ADD functions#3609georgesittas merged 3 commits intomainfrom
georgesittas merged 3 commits intomainfrom
Conversation
georgesittas
approved these changes
Jun 6, 2024
Owner
|
what happens with spark 3.4? |
Collaborator
Author
|
@tobymao The new |
Owner
|
you need to make sure it’s not default so that 3.4 still works |
georgesittas
reviewed
Jun 6, 2024
georgesittas
approved these changes
Jun 6, 2024
fresioAS
pushed a commit
to fresioAS/sqlglot
that referenced
this pull request
May 3, 2026
* feat(spark, databricks): Support for DATE_ADD functions * PR Feedback 1 * PR Feedback 2
RichardHughes-amp
added a commit
to RichardHughes-amp/sqlglot
that referenced
this pull request
May 4, 2026
…Parser DatabricksParser inherits SparkParser._build_dateadd, which already correctly disambiguates 2-arg (-> TsOrDsAdd, returns DATE) from 3-arg (-> TimestampAdd, preserves type). The Databricks-level overrides were reintroducing the bug that PR tobymao#3609 intended to fix at the Spark level. Retain the TsOrDsAdd -> DATE typing entry in spark.py; the Hive -> Spark -> Databricks descent is covered by test_hive_chain_date_add_descent. Note: the 3-arg `date_add(unit, value, expr)` / `dateadd` form is a Databricks-only extension (Spark OSS exposes this only as TIMESTAMPADD). SparkParser intentionally handles it to support Databricks, which is why inheritance is the right scoping here.
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.
Fixes #3607
Until now Hive and it's child dialects supported
DATE_ADD(startDate, numDays)which had "hardcoded" the unit toDAYSand returned aDATE.Spark3 (testing on 3.5.1) and Databricks have introduced support for
DATE_ADD(unit, value, expr)(alias ofTIMESTAMPADDandDATEADD) which instead returns aTIMESTAMP.Note that the old / 2-arg version is still supported alongside the new one and should be preserved to ensure the
DATEvsTIMESTAMPsemantics.