[CT-2897] [Feature] Suppress stack trace when a model contract is violated
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
### Is this your first time submitting a feature request?
- [X] I have read the [expectations for open source contributors](https://docs.getdbt.com/docs/contributing/oss-expectations)
- [X] I have searched the existing issues, and I could not find an existing issue for this feature
- [X] I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion
### Describe the feature
When a model contract fails, there's a lot of guff that gets in the way of seeing the actual issue, and comes dangerously close to spilling out of most consoles (Cloud IDE shown here, but I run my VS Code console smaller than this):
```
Compilation Error in model my_first_dbt_model (models/example/my_first_dbt_model.sql)
This model has an enforced contract that failed.
Please ensure the name, data_type, and number of columns in your contract match the columns in your model's definition.
| column_name | definition_type | contract_type | mismatch_reason |
| -------------------------- | --------------- | ------------- | --------------------- |
| ID | TEXT | FIXED | data type mismatch |
| THIS_COLUMN_DOESNT_EXIST | | TEXT | missing in definition |
| THIS_COLUMN_SHOULDNT_EXIST | TIMESTAMP_LTZ | | missing in contract |
> in macro assert_columns_equivalent (macros/materializations/models/table/columns_spec_ddl.sql)
> called by macro default__get_assert_columns_equivalent (macros/materializations/models/table/columns_spec_ddl.sql)
> called by macro get_assert_columns_equivalent (macros/materializations/models/table/columns_spec_ddl.sql)
> called by macro snowflake__create_view_as_with_temp_flag (macros/adapters.sql)
> called by macro snowflake__create_view_as (macros/adapters.sql)
> called by macro create_view_as (macros/materializations/models/view/create_view_as.sql)
> called by macro default__get_create_view_as_sql (macros/materializations/models/view/create_view_as.sql)
> called by macro get_create_view_as_sql (macros/materializations/models/view/create_view_as.sql)
> called by macro statement (macros/etc/statement.sql)
> called by macro create_or_replace_view (macros/materializations/models/view/create_or_replace_view.sql)
> called by macro materialization_view_snowflake (macros/materializations/view.sql)
> called by model my_first_dbt_model (models/example/my_first_dbt_model.sql)
1 of 2 ERROR creating sql view model dbt_jlabes.my_first_dbt_model ............. [ERROR in 0.88s]
Finished running node model.my_new_project.my_first_dbt_model
```
It would be better if instead it was like this:
```
Compilation Error in model my_first_dbt_model (models/example/my_first_dbt_model.sql)
This model has an enforced contract that failed.
Please ensure the name, data_type, and number of columns in your contract match the columns in your model's definition.
| column_name | definition_type | contract_type | mismatch_reason |
| -------------------------- | --------------- | ------------- | --------------------- |
| ID | TEXT | FIXED | data type mismatch |
| THIS_COLUMN_DOESNT_EXIST | | TEXT | missing in definition |
| THIS_COLUMN_SHOULDNT_EXIST | TIMESTAMP_LTZ | | missing in contract |
1 of 2 ERROR creating sql view model dbt_jlabes.my_first_dbt_model ............. [ERROR in 0.88s]
Finished running node model.my_new_project.my_first_dbt_model
```
### Describe alternatives you've considered
_No response_
### Who will this benefit?
People who like concise and usable error messages. I guess this is happening since it's a compiler error, and normally the macros that got us to a compilation error are highly relevant. But in this case they're 100% internal macros so it's not useful.
### Are you interested in contributing this feature?
_No response_
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.