Skip to content

[Bug] relation "<model>__dbt_tmp" already exists errors appearing #12188

@tobiascadee

Description

@tobiascadee

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When running models with table materialisation, this error will come up irregularly:
relation "<model>__dbt_tmp" already exists
I have already tried using a pre hook to drop the tmp tables if they exist but it does not work.

Expected Behavior

Model to just run

Steps To Reproduce

  1. dbt project possible relevant config:
models:
  data_transformations:
    +on_schema_change: "sync_all_columns"
    +bind: false
    +incremental_strategy: "merge"

    staging:
      +materialized: view
      +schema: staging

Relevant log output

12:10:38  2 of 20 ERROR creating sql incremental model dbt_tobias.stg_ios__identities .... [ERROR in 43.83s]
12:11:04    Database Error in model stg_ios__identities (models/staging/ios/stg_ios__identities.sql)
  relation "stg_ios__identities__dbt_tmp" already exists
  compiled code at target/run/data_transformations/models/staging/ios/stg_ios__identities.sql

Environment

- OS: macOS Tahoe 26.1
- Python: 3.11.11
- dbt-core: 1.9.10
- dbt-redshift: 1.9.5

Which database adapter are you using with dbt?

redshift

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions