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

Cannot change between view and distributed table on cluster #345

Open
krisnej opened this issue Aug 23, 2024 · 0 comments
Open

Cannot change between view and distributed table on cluster #345

krisnej opened this issue Aug 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@krisnej
Copy link

krisnej commented Aug 23, 2024

Describe the bug

We want to use dbt on a Clickhouse cluster with two nodes. As far as I can tell, you cannot switch from a view materialization to a distributed table, or vice versa.

Steps to reproduce

profiles.yml is set up with on_cluster.

Model materialized as view:

{{  
    config(  
        materialized='view',  
    )  
}}  
  
SELECT 1 as id

Run dbt build, successfully creates the view.
Switch model to distributed_table:

{{  
    config(  
	materialized='distributed_table',
        order_by='id',
        sharding_key='cityHash64(id)',
        engine='ReplacingMergeTree'
    )  
}}  
  
SELECT 1 as id

Run dbt build again, this fails:

 Database Error in model test (models/test.sql)
  :HTTPDriver for [hostname]:[port] returned response code 404)
   Code: 60. DB::Exception: Table [schema].`test_local` doesn't exist. (UNKNOWN_TABLE) (version 24.1.8.22 (official build))

Also a run with --full-refresh does not help.

If you start with a clean distributed table (distributed + local table) and change the materialization to a view, it succeeds, by changing the test table to a view, but the test_local table remains.

Expected behaviour

Changing materialization deletes and creates the expected tables/view.

Configuration

Environment

  • dbt version: 1.8.4
  • dbt-clickhouse version: 1.8.1
  • Python version: 3.11

ClickHouse server

  • ClickHouse Server version: 24.1.8.22

Is this behaviour intended or expected? If not, a fix would be appreciated, as our current workaround for this is to drop and recreate the whole schema.

@krisnej krisnej added the bug Something isn't working label Aug 23, 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