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

Lost data when updating materialized view #383

Open
the4thamigo-uk opened this issue Nov 13, 2024 · 1 comment
Open

Lost data when updating materialized view #383

the4thamigo-uk opened this issue Nov 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@the4thamigo-uk
Copy link
Contributor

Describe the bug

Steps to reproduce

  1. Establish a high-volume realtime data feed into a CH table A
  2. Set up a materialized view writing data to table B
  3. Run dbt to update the materialized view whilst the data feed is running

Expected behaviour

The update of the materialized view should be atomic, but data is lost in between the drop and the create.

For altering the SQL we should use the atomic ALTER TABLE ... MODIFY QUERY https://clickhouse.com/docs/en/sql-reference/statements/alter/view

@the4thamigo-uk the4thamigo-uk added the bug Something isn't working label Nov 13, 2024
@the4thamigo-uk
Copy link
Contributor Author

the4thamigo-uk commented Nov 20, 2024

@BentsiLeviav I would like to implement a solution for this. I think we need to try to perform the ALTER statement, but if it fails, then to fallback to the DROP and CREATE approach. However, the problem I have is that there doesnt seem to be a way in jinja or dbt to catch the exception if the ALTER fails. I think maybe the only way is to add something to the adapter? Do you have any ideas/advice?

the4thamigo-uk added a commit to the4thamigo-uk/dbt-clickhouse that referenced this issue Nov 21, 2024
the4thamigo-uk added a commit to the4thamigo-uk/dbt-clickhouse that referenced this issue Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant