Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Updating a data type detail (e.g. size) results in a breaking change on the contract for versioned models #11186

Open
2 tasks done
marvingeerken opened this issue Jan 6, 2025 · 7 comments
Assignees
Labels
backport 1.9.latest bug Something isn't working cloud Issues related to dbt Cloud model_contracts regression

Comments

@marvingeerken
Copy link

marvingeerken commented Jan 6, 2025

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

We have a model materialized as a table with an enforced contract and a version 1. If we change a column's data type from varchar(1) to varchar(2), this change is detected as a breaking change.

We already identified that it only happens when a version is added. The materialization does not matter.

Expected Behavior

As described in https://docs.getdbt.com/reference/resource-configs/contract#size-precision-and-scale it should not result in a breaking change.

Steps To Reproduce

  1. Create model with a varchar column, an enforced contract and version.
-- bug_mgeerken_dtype_contract.sql
select 'asd' as test_col
models:
  - name: bug_mgeerken_dtype_contract
    config:
      contract:
        enforced: true
    versions:
      - v: 1
    columns:
      - name: test_col
        data_type: varchar(3)
  1. Deploy to staging/production deployment environment.

  2. Change the varchar size on that contract and run deferring to the previous state.

data_type: varchar(3) --> data_type: varchar(4)

Relevant log output

10:27:08 Encountered an error:
Breaking change to contract Error in model bug_mgeerken_dtype_contract (models/custom/bugs/bug_mgeerken_dtype_contract.sql)
  While comparing to previous project state, dbt detected a breaking change to an enforced contract.
    - Columns with data_type changes: 
      - test_col (varchar(3) -> varchar(4))
  Consider making an additive (non-breaking) change instead, if possible.
  Otherwise, create a new model version: https://docs.getdbt.com/docs/collaborate/govern/model-versions

Environment

dbt Cloud: Latest (2025.2.11+cf5e53e)

Which database adapter are you using with dbt?

snowflake

Additional Context

It might be related to the following release:

@marvingeerken marvingeerken added bug Something isn't working triage labels Jan 6, 2025
@dbeatty10 dbeatty10 added the cloud Issues related to dbt Cloud label Jan 16, 2025
@aranke
Copy link
Member

aranke commented Feb 12, 2025

@marvingeerken Thanks for the report here!

Can you please provide some more context about the model, such as whether it is an incremental model?

I'm not able to replicate this issue for a non-incremental model on my end.

Thanks!

@marvingeerken
Copy link
Author

marvingeerken commented Feb 12, 2025

@aranke Thanks for your feedback. It was a {{ table }}. I validated it in different scenarios and projects before I created this issue. However, I just tested it again and don't get the error anymore. With the cloud's latest version its hard to reproduce it now.

My test was on my own dbt Cloud account. If I face the issue again on my clients projects, I would ping you again. IMO we can close it.

@aranke
Copy link
Member

aranke commented Feb 12, 2025

Great, closing the issue for now.
Please feel free to reopen if this happens again.
Thanks!

@aranke aranke closed this as completed Feb 12, 2025
@marvingeerken marvingeerken changed the title [Bug] Updating a data type detail (e.g. size) results in a breaking change on the contract [Bug] Updating a data type detail (e.g. size) results in a breaking change on the contract for versioned models Feb 28, 2025
@marvingeerken
Copy link
Author

Hey @aranke! I have identified why I wasn't able to recreate the error outside my clients project. On my test I haven't had a model version added. Can you please investigate again? (I have no permission to reopen the issue. Hope this message finds you well.)

@joellabes joellabes reopened this Mar 1, 2025
@liamfmck95
Copy link

I wondered whether I could add a similar scenario to this issue. I have updated the data type of a column but only it's case (i.e. decimal(6,5) to DECIMAL(6,5)) and this was treated as a breaking change. I also noticed that if I added a space after the comma within the data type, this would also result in a breaking change error. Since this change would not actually cause any breakage in the model, tests or downstream usage, I don't think these types of changes, as well as the initial issue, should be treated as a breaking change.

@joellabes
Copy link
Contributor

@liamfmck95 could you open this as a new feature idea? It's a reasonable point but slightly different from this

@liamfmck95
Copy link

Thanks @joellabes , I have added this now #11352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.9.latest bug Something isn't working cloud Issues related to dbt Cloud model_contracts regression
Projects
None yet
Development

No branches or pull requests

6 participants