Closed the-ALAM closed 7 months ago
ah yes that sounds like a real bug, will look into it-- thank you!
huh when I ran this locally with my jaffle shop project I got a dbt (not a DuckDB) compilation error when I tried to name a model "Orders.sql":
05:11:57 Completed with 1 error and 0 warnings:
05:11:57
05:11:57 Compilation Error in model Orders (models/Orders.sql)
When searching for a relation, dbt found an approximate match. Instead of guessing
which relation to use, dbt will move on. Please delete "jaffle_shop"."main"."orders", or rename it to be less ambiguous.
Searched for: "jaffle_shop"."main"."Orders"
Found: "jaffle_shop"."main"."orders"
> in macro load_cached_relation (macros/adapters/relation.sql)
> called by macro materialization_table_duckdb (macros/materializations/table.sql)
> called by model Orders (models/Orders.sql)```
that was against dbt-core 1.7.11; do you not see that? Or am I missing something about how to reproduce the error you got with the `tmp` renaming issue not working?
the error you have is because the orders
identifier exists already, and if you dropped the orders
and rerun the Orders
model it should work on your end and to see the tmp
try adding the --debug option to your command.
1- sorry i missed a step from the repro which is: 'attaching a postgres database the model will be build on' eg;
extensions:
- postgres
attach:
- path: 'postgres:host= password= user= dbname='
alias: pg
i didnt add it since i wanted to focus our attention on duckdb
2- second i could've made this issue in duckdb since i suspected the issue is from duckdb except for this https://github.com/duckdb/duckdb/issues/10356#issuecomment-1914089650, so given duckdb's deliberate identifier case insensitivity and that the problem happened with DBT in combination with duckdb, i though it's only rational that i post here first and see if we can reach a solution together
the fix should come from duckdb's support for postgres, not a work around from your end
description
Zipcode
model with it's materialization set totable
.reproduction Steps
Zipcode
- or any other name with the first letter capitalized - and set the materialization totable
.expected Behavior
Zipcode
model should be created successfully without encountering any errors.detailed Behavior
__dbt_tmp
)__dbt_backup
)__dbt_tmp
→ ``)actual Behavior
Zipcode
model.Runtime Error in model {model_name} (models_{dir_name}\{model_name}.sql) Failed to execute query "ALTER TABLE {schema_name}.Zipcode__dbt_tmp RENAME TO Zipcode": ERROR: relation "{schema_name}.zipcode__dbt_tmp" does not exist
discovery Process
Zipcode
model with materialization set totable
.ALTER TABLE
statement to fail since it can't find the relation because the name is changed from the name to the lower-cased name.environment
additional Information
incremental
and dropping the table beforehand, the issue does not occur.