Repository navigation
fix(materialized_view): persist docs before a refreshable view's initial refresh - #811
Open
gedaliakliger wants to merge 3 commits into
Open
gedaliakliger wants to merge 3 commits into
gedaliakliger wants to merge 3 commits into
Conversation
…ial refresh With catchup=False a refreshable materialized view starts its first refresh when it is created. A non-APPEND refresh replaces the target table with one built from the structure the target had when the refresh started, so the comments persist_docs added while it ran were lost. They are now added before the views are created. Fixes ClickHouse#581
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
With
catchup=Falsea refreshable materialized view is created withoutEMPTY, so ClickHouse starts its first refresh at once. A non-APPEND refresh replaces the target with a table built from the structure the target had when the refresh started, so the commentspersist_docsadded while it ran were lost once the refresh finished.clickhouse__create_mvsnow persists the docs on the target table before it creates the views, when the model is refreshable and the view is not created withEMPTY. This covers the first run and--full-refresh. Not covered: a plaindbt runthat recreates a missing view throughclickhouse__update_mv, where only comments new in that run can still be lost.The new test uses a slow query so the refresh outlives the run; it fails on
mainand passes here. Run locally on a single-node ClickHouse 26.3: thematerialized_viewandpersist_docsintegration tests over HTTP and the refreshable MV tests over the native driver. Cluster, Cloud and newer server versions are left to CI.Fixes #581
Checklist
Note
Low Risk
Narrows timing of existing
persist_docsfor one materialized-view path; low blast radius with targeted integration coverage.Overview
Fixes lost
persist_docscomments on refreshable materialized views whencatchup=False. WithoutEMPTY, ClickHouse starts the first refresh immediately; a non-APPEND refresh rebuilds the target from the schema snapshot taken at refresh start, so docs applied at the end ofdbt runwere wiped once the refresh finished.clickhouse__create_mvsnow callspersist_docson the target before creating the views when the model is refreshable and the view is not created withEMPTY(first run and--full-refresh). A changelog entry and an integration test (sleepEachRowso the refresh outlives the run) assert table and column comments insystem.tables/system.columnsafter the refresh completes.Reviewed by Cursor Bugbot for commit 77801e0. Bugbot is set up for automated code reviews on this repo. Configure here.