-
Notifications
You must be signed in to change notification settings - Fork 239
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
Not dropping table for incremental full refresh with delta #287
Not dropping table for incremental full refresh with delta #287
Conversation
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Sindre Grindheim.
|
1 similar comment
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Sindre Grindheim.
|
The cla-bot has been summoned, and re-checked this pull request! |
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Sindre Grindheim.
|
The cla-bot has been summoned, and re-checked this pull request! |
The cla-bot has been summoned, and re-checked this pull request! |
Hi @grindheim sorry for the delay in response, gathering context now , and was wondering if you wouldn't mind updating your code to be in parity with main and re-push up so we can start to get some hanging tests running in the meantime. |
…indheim/UpdateIncrementalFullRefreshDelta
@McKnight-42 Updated the code. Let me know if there's anything else you'd like me to do. |
@grindheim for some reason the unit test didn't kick off and looks like we might need to now also update to main to take get access to our newly added black formatter and pre-commit functionality in-order for the code-quality check to pass. i'm hoping doing this will trigger both tests if not I'll keep looking into why the unit test didn't trigger. sorry for any inconvenience. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay @grindheim! Hoping we can get this merged soon, it'll definitely help out folks who are running into this issue. One small comment from me on the specific code change.
{% if existing_relation.is_view or file_format != 'delta' %} | ||
{% do adapter.drop_relation(existing_relation) %} | ||
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two quick thoughts here:
- I think this conditional logic can be simplified to avoid the nested
if
statements - We need to check both that the table already exists in Delta format, and will be created in Delta format
So further up:
{% set is_delta = (file_format == 'delta' and existing_relation.is_delta) %}
And then:
{% elif existing_relation.is_view or (full_refresh_mode and not is_delta) %}
{% do adapter.drop_relation(existing_relation) %}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the thoughts and suggestions, and sorry for my delay. I've implemented and pushed your suggested changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grindheim Noticed one thing in the logic that doesn't look quite right. If you could take a look in the next few days, we can try to get this in for v1.2!
dbt/include/spark/macros/materializations/incremental/incremental.sql
Outdated
Show resolved
Hide resolved
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
Just going to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @grindheim! Glad to finally get this in :)
### Description Ports the upstream change: Not dropping table for incremental full refresh with delta (dbt-labs/dbt-spark#287)
) * Not dropping table for incremental full refresh with delta * Updated changelog * Simplified conditional logic according to suggestion * Updated changelog * Only drop table if not delta table Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com> * Update changelog, trigger CircleCI tests Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com> Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
resolves 286
Description
Since the spark__create_table_as implementation already runs create or replace table if the file format is delta, this PR disables dropping the table first in this case. The advantage being that it will preserve grants on the table, in addition to it simply being unnecessary.
Checklist
CHANGELOG.md
and added information about my change to the "dbt-spark next" section.