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

Materialized Views not updating cache #9959

Merged
merged 20 commits into from
Apr 24, 2024
Merged

Conversation

McKnight-42
Copy link
Contributor

@McKnight-42 McKnight-42 commented Apr 16, 2024

linked issue: https://github.com/dbt-labs/adapters-team-private/issues/127
this pr would eventually need to be backported to 1.6 and have similar changes made in dbt-adapters

Problem

We do not appear to be updating cache for MV functionality like drops, renames, adds which is causing catalog mismatch errors in runs especially between MV's that are dependent on each other

Solution

Current:
we will remove materialized_view from the renameable_relation variable thus reverting us to the create and drop functionality that we were seeing before the introduction in #9682

Attempted:
Update our various macros to either use commonly used Python functions from the base impl.py such as drop_relation, and rename_relation or use the more primitive version designed in the base adapter e.g cache_dropped and cache_renamed to ensure we are maintaining parity with database expectation.

TODO:

  • Add changelog entry after a solution is found
  • Create a version for dbt-postgres on main
  • Double check on backport to 1.6 in core

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@McKnight-42 McKnight-42 requested a review from mikealfare April 16, 2024 19:07
@McKnight-42 McKnight-42 self-assigned this Apr 16, 2024
@cla-bot cla-bot bot added the cla:yes label Apr 16, 2024
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link

codecov bot commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.67%. Comparing base (7122b31) to head (6fa2619).

Additional details and impacted files
@@              Coverage Diff               @@
##           1.7.latest    #9959      +/-   ##
==============================================
- Coverage       86.69%   86.67%   -0.02%     
==============================================
  Files             179      179              
  Lines           26662    26662              
==============================================
- Hits            23115    23110       -5     
- Misses           3547     3552       +5     
Flag Coverage Δ
integration 83.50% <ø> (-0.10%) ⬇️
unit 65.03% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -39,7 +39,7 @@
on {{ relation }} {% if index_config.type -%}
using {{ index_config.type }}
{%- endif %}
({{ comma_separated_columns }});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing ;as it doubles up with one at end of statement causing error

…c versions incase we are not catching the dispatch as a layer of call or in drop case of it being a explicit return call
@McKnight-42 McKnight-42 added the Skip Changelog Skips GHA to check for changelog file label Apr 18, 2024
@McKnight-42 McKnight-42 requested a review from mikealfare April 19, 2024 19:26
@McKnight-42
Copy link
Contributor Author

The current fix seems to be to remove ability of Postgers to try and rename through the workflow we have in get_replace_sql this will send us back to the behavior of create and drop the user was experiencing before updating.

the cause seems to be a dependency between renaming backup temporary relation to the model name that causes an issue during drop and cascade when another model that is also a materialized view refs it.

@McKnight-42 McKnight-42 marked this pull request as ready for review April 23, 2024 23:17
@McKnight-42 McKnight-42 requested a review from a team as a code owner April 23, 2024 23:17
@colin-rogers-dbt colin-rogers-dbt merged commit ad0df69 into 1.7.latest Apr 24, 2024
61 checks passed
@colin-rogers-dbt colin-rogers-dbt deleted the mcknight/127 branch April 24, 2024 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes Skip Changelog Skips GHA to check for changelog file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants