jwills / target-duckdb

A Singer.io target for DuckDB
Other
17 stars 12 forks source link

Schema is not created if it already exists in another database(catalog) #41

Closed jaceksan closed 5 months ago

jaceksan commented 5 months ago

I loaded data to database GDP_DEV into multiple schemas using Meltano profile gdp_dev. Then I executed meltano with profile gdp_staging using GDP_STAGING database. Same schemas should be populated into this database. But, new schemas are not created and the execution fails with "schema does not exist".

Root cause: target-duckdb checks if the schema exists with this query:

SELECT LOWER(schema_name) schema_name FROM information_schema.schemata 
WHERE LOWER(schema_name) = ?

The query does not contain a predicate filtering to the current catalog/database. So it finds the already existing schema in the first already populated database.

jaceksan commented 5 months ago

It's already been fixed: commit 4fb84187e2e72694d93f4766dce8586591632072 Author: Edgar Ramírez Mondragón edgarrm358@gmail.com Date: 7/23/23, 1:50 AM Check catalog name when looking for existing schemas