Repository navigation
fix: warn when catchup and repopulate_from_mvs_on_full_refresh are both set - #796
Open
m-tahoon1612 wants to merge 2 commits into
Open
m-tahoon1612 wants to merge 2 commits into
m-tahoon1612 wants to merge 2 commits into
Conversation
…th set A materialized view with catchup enabled that writes into a dbt table model with repopulate_from_mvs_on_full_refresh=True backfills the target twice on a full refresh. Log a warning when both are set. Fixes ClickHouse#616
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.
Summary
A materialized view that writes into an explicit target table (
materialization_target_table(ref(...))) backfills that table when it is created or fully refreshed ifcatchup=True, which is the default. The target table can also be configured withrepopulate_from_mvs_on_full_refresh=True, which rebuilds it on a full refresh by running the SQL of every MV that points to it. With both enabled, adbt run --full-refreshloads the same rows twice. The docs already say not to combine them, but nothing tells the user when they do.This PR adds that check to the MV materialization in explicit target mode. When the view has
catchupenabled, it looks the target table up in the dbt graph and, if that model setsrepopulate_from_mvs_on_full_refresh=True, logs a warning naming both models and the two ways to fix it.It is a warning rather than an error on purpose. Because
catchupdefaults toTrue, a project that only setrepopulate_from_mvs_on_full_refresh=Trueon the target table already has both enabled, and failing the run would break it on upgrade.Fixes #616
Testing:
TestCatchupAndRepopulateWarningintest_table_repopulate_from_mvs_on_full_refresh.py: both settings on logs the warning on a regular run and on--full-refresh; onlycatchupon, and onlyrepopulate_from_mvs_on_full_refreshon withcatchup=False, log no warning. The first case fails without the macro change.tests/integration/adapter/materialized_view55 passed (parallel and sequential),tests/integration/adapter/basic26 passed, 1 skipped (needs a cluster), unit tests 101 passed.make lintchecks pass.Checklist
docswas updated with further explanations or tutorialsNote
Low Risk
Non-breaking advisory warning during MV runs; no change to refresh behavior or data paths beyond new logging.
Overview
Adds a runtime warning in explicit-target materialized view mode when
catchup=True(the default) writes to a table model that also hasrepopulate_from_mvs_on_full_refresh=True, since a full refresh can backfill the same target twice and duplicate data.The MV materialization calls a new
clickhouse__warn_if_target_repopulates_from_mvsmacro (warning only, not a compile error) that resolves the target from the dbt graph and points users to disable one of the two settings. Docs note that dbt-clickhouse logs this warning, and integration tests assert the warning appears only when both flags are on.Reviewed by Cursor Bugbot for commit eb8411b. Bugbot is set up for automated code reviews on this repo. Configure here.