fix(table): ducklake needs extra commit betwen 2 alter table rename - #647
fix(table): ducklake needs extra commit betwen 2 alter table rename#647AntoineGiraud wants to merge 2 commits into
Conversation
cf. issue #646 otherwise, we had an error on `dbt build -s my_table` on 2nd run (drop / create table) ``` 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. ```
|
@AntoineGiraud ah so the idea is that in ducklake we can't do the rename op first and then backup later? I think the issue with this as-written is that it will break the backup behavior for any other table definition, so if this is what ducklake needs we need to think through how to special-case it |
|
Hi @jwills, Thanks for your replay, indeed, my edit wasn't the right one ! i took more time with a colleague, to repeat / translate our -----------------------------------------------------------
-- init ducklake with 1st table load (as in dbt-duckdb)
-----------------------------------------------------------
ATTACH 'ducklake:~/my_ducklake.ducklake' AS my_ducklake;
USE my_ducklake;
create schema if not exists stg;
show tables from my_ducklake.stg;
-----------------------------------------------------------
-- 1st time `dbt run -s coucou`
-----------------------------------------------------------
begin;
create table stg.coucou__dbt_tmp as select 'coucou' nom;
alter table stg.coucou__dbt_tmp rename to coucou;
commit;Nxt up, 2nd time
-----------------------------------------------------------
-- 2nd time `dbt run -s coucou`
-----------------------------------------------------------
begin transaction;
create table stg.coucou__dbt_tmp as select 'coucou' nom;
alter table stg.coucou rename to coucou__dbt_backup ;
alter table stg.coucou__dbt_tmp rename to coucou;
commit;
drop table stg.coucou__dbt_backup ;Adding commit between 2 alter rename works : -----------------------------------------------------------
-- 2nd time `dbt run -s coucou`
-----------------------------------------------------------
begin TRANSACTION;
create table stg.coucou__dbt_tmp as select 'coucou' nom;
alter table stg.coucou rename to coucou__dbt_backup;
commit;
------------
begin TRANSACTION;
alter table stg.coucou__dbt_tmp rename to coucou;
commit;
drop table stg.coucou__dbt_backup ;I'll start an issue on DuckLake side to see what there thinking on it ... |
|
Here is the update / status from ducklake side !
I've installed the latest ducklake extension ( My previous dbt failure went away :)
I'm canceling the PR & closing the linked issue |
cf. issue #646
otherwise, we had an error on
dbt build -s my_tableon 2nd run (drop / create table)and we already did a backup on line 16