ClickHouse / dbt-clickhouse

The Clickhouse plugin for dbt (data build tool)
Apache License 2.0
253 stars 113 forks source link

Atomic view creation in view.sql #368

Closed RachM closed 1 month ago

RachM commented 1 month ago

This PR changes the view creation to use create or replace view, which is atomic.

Previously, dbt-clickhouse would:

  1. Create a new "temporary" view
  2. Drop the current view (eek!)
  3. Rename the new view to the current view

The above 3 steps aren't done in a single transactions, so any queries on the view that occur during the process may get errors that the view doesn't exist.

Ideally, the operations are done in a single, atomic operation. I.e. use create or replace view.

Summary

Checklist

Delete items not relevant to your PR:

CLAassistant commented 1 month ago

CLA assistant check
All committers have signed the CLA.