troubleshooting

Is it possible that a match between the returned `type` and the materialization type of `table_with_connector` is expected?

James Johnston is facing an issue where dbt doesn't see a pre-existing relation and tries to recreate it. He suspects that the mismatch between the returned type and the materialization type of table_with_connector might be the cause. Dylan suggests using create if not exists in the table with connector model SQL file. James confirms that this solution worked. Should the IF NOT EXISTS clause be included in the model files?

Ja

James Johnston (he/him/his)

Asked on Jan 21, 2024

  • Yes, including the IF NOT EXISTS clause in the model files, especially for table_with_connector models, can prevent dbt from trying to recreate existing relations.

  • The IF NOT EXISTS clause ensures that the table creation SQL is only executed if the table does not already exist in the database.

  • While the official examples may not explicitly recommend it, including this clause can improve the efficiency and prevent unnecessary recreation of tables.

  • Dylan's suggestion to use create if not exists in the table with connector model SQL file is a practical solution to avoid the issue of dbt trying to recreate existing tables.

Jan 22, 2024Edited by