-
Notifications
You must be signed in to change notification settings - Fork 117
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
Allow multiple materialized views to write to same target (#280) #364
Allow multiple materialized views to write to same target (#280) #364
Conversation
issue #280 |
e4e9b6d
to
f932efb
Compare
Thank you for your contribution! looking forward to reviewing this |
f932efb
to
798aca9
Compare
3485793
to
e661bfa
Compare
e661bfa
to
277fa45
Compare
277fa45
to
064ed53
Compare
@BentsiLeviav Ok, Ive done this. |
"hackers.sql": MV_MODEL, | ||
} | ||
|
||
def test_create(self, project): |
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.
Could you also test for updates and full refresh?
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.
Yeah I think if you change the model to add or rename MVs, then old ones will be left running, which is incorrect.
Thanks @the4thamigo-uk |
I’ve added the tests through your branch. Regarding the potential issue of unremoved materialized views (MVs): as you mentioned, this situation occurs when a user renames one (or more) of the MVs. What I’ve implemented for now is a query in ClickHouse to identify any MV that matches the pattern of the model name but is not listed in the model. If such an MV is found, a warning is raised to notify the user. I’m hesitant about automatically dropping these MVs, as they could be valid and intentionally separate from the model. Additionally, I’ve updated the README file to include this important information. Let’s monitor this behavior for now. If anyone in the community has a better or safer solution, contributions are welcome! |
Amazing, thanks for finishing this off. I was actually working on this yesterday and implemented a similar thing to drop the dangling views, but as you say this might be dangerous. However, I did change the naming convention for the views so that the view name is always appended after a
|
Summary
Proposed mechanism to support having multiple materialized views pointing to the same target table.
In brief, we add tags to mark blocks of the sql which will form each of the materialized views to be created.
i.e. https://github.com/ClickHouse/dbt-clickhouse/pull/364/files#diff-b1cddf2e5c9b3d08ea2276e5cef4944b06b9744a4076c5970ff5a5edb0140f08R62.
The entire union of all such blocks is used to backfill the target table.
Checklist
Delete items not relevant to your PR: