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

Use builtin timestampadd and timestampdiff functions for dateadd/datediff macros if available. #185

Merged
merged 9 commits into from
Sep 26, 2022

Conversation

ueshin
Copy link
Collaborator

@ueshin ueshin commented Sep 21, 2022

Description

Uses builtin timestampadd and timestampdiff functions for dateadd/datediff macros if available.

The functions timestampadd and timestampdiff have been available since DBR 10.4. Those are equivalent to what dateadd/datediff macros are trying to achieve.

@@ -59,6 +60,19 @@ class DatabricksAdapter(SparkAdapter):

AdapterSpecificConfigs = DatabricksConfig

@available.parse(lambda *a, **k: 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why do we need this @available.parse?

Copy link
Collaborator Author

@ueshin ueshin Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Methods to be exposed to macros need to be marked with @available or its variants.

And without @available.parse, the function will be executed even at parse time that causes InvalidConnectionException because connections are not available at parse time.

A decorator factory to indicate that a method on the adapter will be
exposed to the database wrapper, and will be stubbed out at parse time
with the given function.

@ueshin
Copy link
Collaborator Author

ueshin commented Sep 26, 2022

Thanks! merging.

@ueshin ueshin merged commit 4d08dec into databricks:main Sep 26, 2022
@ueshin ueshin deleted the dateadd_datediff branch September 26, 2022 21:26
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