-
Couldn't load subscription status.
- Fork 123
Description
Hello,
I'm trying DuckLake with dbt
When building a table the 1st time, all goes well (dbt build -s my_table)
When building for the 2nd time (i was expecting a create or replace),
I receive the following message
08:05:32 Failure in model stg_commande (models/hypermarche/stg/stg_commande.sql)
08:05:32 Runtime Error in model stg_commande (models/hypermarche/stg/stg_commande.sql)
Binder Error: Cannot rename table stg_commande__dbt_tmp to stg_commande, since stg_commande__dbt_tmp already exists.
I assume it's happening line 40 in table.sql
-- cleanup
{% if existing_relation is not none %}
{#-- Drop indexes before renaming to avoid dependency errors --#}
{% do drop_indexes_on_relation(existing_relation) %}
{{ adapter.rename_relation(existing_relation, backup_relation) }} --> we already made a backup above on line 16
{% endif %}
{{ adapter.rename_relation(intermediate_relation, target_relation) }}Shall we not just have on line 40 {{ drop_relation_if_exists(existing_relation) }}
as we already did a backup on line 16 {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}
and that we're still in the begin / commit
and that DuckLake gots us covered anyway with snapshots !
By doing so, it works well on my side,
here is a simple PR if it's the right solution :)
Edit : line 16 just initialize the backup_relation table name to be used