Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spark, databricks)!: Support for DATE_ADD functions #3609

Merged
merged 3 commits into from
Jun 7, 2024

Conversation

VaggelisD
Copy link
Collaborator

Fixes #3607

Until now Hive and it's child dialects supported DATE_ADD(startDate, numDays) which had "hardcoded" the unit to DAYS and returned a DATE.

Spark3 (testing on 3.5.1) and Databricks have introduced support for DATE_ADD(unit, value, expr) (alias of TIMESTAMPADD and DATEADD) which instead returns a TIMESTAMP.

Note that the old / 2-arg version is still supported alongside the new one and should be preserved to ensure the DATE vs TIMESTAMP semantics.

sqlglot/dialects/spark.py Outdated Show resolved Hide resolved
sqlglot/dialects/spark.py Show resolved Hide resolved
sqlglot/dialects/spark.py Outdated Show resolved Hide resolved
tests/dialects/test_redshift.py Outdated Show resolved Hide resolved
tests/dialects/test_spark.py Show resolved Hide resolved
@tobymao
Copy link
Owner

tobymao commented Jun 6, 2024

what happens with spark 3.4?

@VaggelisD
Copy link
Collaborator Author

VaggelisD commented Jun 6, 2024

@tobymao The new DATE_ADD version does not seem supported on 3.4.3 so it must be a 3.5+ feature . What should be our approach in such situations, support the latest dialect?

@tobymao
Copy link
Owner

tobymao commented Jun 6, 2024

you need to make sure it’s not default so that 3.4 still works

@VaggelisD VaggelisD changed the title feat(spark, databricks): Support for DATE_ADD functions feat(spark, databricks)!: Support for DATE_ADD functions Jun 6, 2024
@georgesittas georgesittas merged commit d6cfb41 into main Jun 7, 2024
6 checks passed
@georgesittas georgesittas deleted the vaggelisd/db_dateadd branch June 7, 2024 00:01
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.

Redshift DATEADD -> Databricks DATE_ADD
3 participants