Skip to content

'tmp_relation' is undefined when altering a column's datatype on an incremental model #248

@baldwicc

Description

@baldwicc

We're seeing error messages in v1.7.3 when the datatype of a column is altered (but the column name remains the same).

04:07:16  Running with dbt=1.7.15
04:07:16  Registered adapter: synapse=1.7.3
12:34:56    Compilation Error in model example_model_name (models/xxx/example_model_name.sql)
  'tmp_relation' is undefined
  
  > in macro alter_column_type (macros/adapters/columns.sql)
  > called by macro materialization_incremental_default (macros/materializations/models/incremental/incremental.sql)
  > called by model example_model_name (models/xxx/example_model_name.sql)

Root cause appears to be the upstream fabric adaptor not supporting ALTER TABLE, but also having it's own bug in this macro where tmp_relation is indeed never defined:

dbt-msft/dbt-sqlserver:
https://github.com/dbt-msft/dbt-sqlserver/blob/f789ab0815b926bd68af6e901cd0e33b2895db3f/dbt/include/sqlserver/macros/adapters/columns.sql#L1-L18

microsoft/dbt-fabric:
https://github.com/microsoft/dbt-fabric/blob/45dacbc87e1b45602dd46218c75f3aaa441dbb95/dbt/include/fabric/macros/adapters/columns.sql#L55-L117

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions