dbt-labs / dbt-labs/dbt-adapters

[Feature] Support pre-flight checks for dbt model contacts on dynamic tables

Open
#726 11 comments 1 reaction 0 assignees View on GitHub
feature:dynamic-tables feature:model-contracts pkg:dbt-snowflake type:enhancement
Dominant language
Python
Stars
233
Forks
362
Avg merge
3d 22h
Merged PRs (30d)
9

Description

### Is this a new bug in dbt-snowflake?

- [X] I believe this is a new bug in dbt-snowflake
- [X] I have searched the existing issues, and I could not find an existing issue for this bug

### Current Behavior

When I deploy models materialized as **table** or **view** - the contract is verified and in case of discrepancy I receive the expected error
> Compilation Error in model your_model (models\your_model_v1.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.

When I deploy models materialized as **dynamic_table** - the **contract verification does not seem to happen**, so can I release things that have not been vetted and can violate the contract.

This behavior is completely unexpected and when unnoticed will have nasty consequences discovered only on target environment (as was my case).

### Expected Behavior

The models deployed as dynamic_tables should have the contract enforced, similarly to other materializations.

At minimum - there should be some warning emitted that this is not the case for dynamic tables

### Steps To Reproduce

1. take a simple model with enforced contract
2. break the contract, eg by renaming one of the columns in model
3. observe that the deployment fails properly when materialization is set to 'table'
4. observe that it passes without error when materialization is set to 'dynamic_table' no matter if you use --full-refresh or not

### Relevant log output

_No response_

### Environment

```markdown
- OS:Windows 10
- Python:3.10.5
- dbt-core: 1.7.4
- dbt-snowflake: 1.7.1
```

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.