Skip to content

[CT-2401] [Bug] Adding a new column to a model with an enforced contract should not be a breaking change #7332

@jtcohen6

Description

@jtcohen6

Reported in #7065 (comment)

Reproduction case

-- models/sometable.sql
select 1 as id
models:
  - name: sometable
    config:
      contract:
        enforced: true
    columns:
      - name: order_id
        data_type: number
      - name: order_name
        data_type: varchar

Run:

$ mkdir state
$ dbt ls
$ mv target/manifest.json state/

Change the yaml to:

models:
  - name: sometable
    config:
      contract:
        enforced: true
    columns:
      - name: order_id
        data_type: number
      - name: order_name
        data_type: varchar
      - name: categories
        data_type: varchar
$ dbt ls -s state:modified --state state/
10:38:49  Running with dbt=1.5.0-b5
10:38:50  Found 2 models, 0 tests, 0 snapshots, 1 analysis, 536 macros, 0 operations, 1 seed file, 0 sources, 0 exposures, 0 metrics, 0 groups
10:38:50  Encountered an error:
Contract Error in model sometable (models/sometable.sql)
  There is a breaking change in the model contract because column definitions have changed; you may need to create a new version. See: https://docs.getdbt.com/docs/collaborate/publish/model-versions

Also

Let's rename ModelContractError to ModelContractBreakingChangeError, to better disambiguate it from ContractError (when the model's contract fails at build time).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions