Search code examples
clickhousedbt

dbt creates temporary tables for incremental load, is there a way to auto delete these?


whenever i create a table with incremental materialisation configs i end up having temporary tables, is there a way to get rid of these tables?

dim_table__dbt_new_data_01128add_58b2_48e7_a82b_10baac4d9ec6

{{
    config(
        materialized='incremental',
        on_schema_change='sync_all_columns',
        unique_key='id',
        incremental_strategy='delete+insert',
        tags = ['tag']
    ) }} WITH src_table AS (
    select * from {{ref('src_table')}} )

SELECT
    * FROM
    (
        SELECT
            *,
            row_number() OVER (
                PARTITION BY
                    id
                ORDER BY
                    updated_at DESC
            ) AS r
        FROM
            src_table
    ) where
    r = 1

{% if is_incremental() %}

  where updated_at > (select max(updated_at) from {{ this }})

{% endif %}

Environment: dbt-clickhouse version: 1.4.8 ClickHouse Server version: 23.3.8


Solution

  • issue got fixed here, this behaviour is a result of failed metallisation

    https://github.com/ClickHouse/dbt-clickhouse/issues/229