Skip to content

Commit

Permalink
Update website/docs/reference/resource-configs/contract.md
Browse files Browse the repository at this point in the history
  • Loading branch information
runleonarun authored Oct 11, 2023
1 parent 83258ed commit 1e418c7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion website/docs/reference/resource-configs/contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The `data_type` defined in your YAML file must match a data type your data platf

When dbt is comparing data types, it will not compare granular details such as size, precision, or scale. We don't think you should sweat the difference between `varchar(256)` and `varchar(257)`, because it doesn't really affect the experience of downstream queriers. If you need a more-precise assertion, it's always possible to accomplish by [writing or using a custom test](/guides/best-practices/writing-custom-generic-tests).

You need to specify a varchar size or numeric scale, otherwise dbt relies on default values. For example, if a `numeric` type defaults to a precision of 38 and a scale of 0, then the numeric column stores 0 digits to the right of the decimal (it only stores whole numbers), which might cause it to fail contract enforcement. To avoid this implicit coercion, specify your `data_type` with a nonzero scale, like `numeric(38, 6)`. dbt Core 1.7 and higher provides an error if you don't specify precision and scale when providing a numeric data type.
Just remember, you need to specify a varchar size or numeric scale, otherwise dbt relies on default values. For example, if a `numeric` type defaults to a precision of 38 and a scale of 0, then the numeric column stores 0 digits to the right of the decimal (it only stores whole numbers), which might cause it to fail contract enforcement. To avoid this implicit coercion, specify your `data_type` with a nonzero scale, like `numeric(38, 6)`. dbt Core 1.7 and higher provides an error if you don't specify precision and scale when providing a numeric data type.

## Example

Expand Down

0 comments on commit 1e418c7

Please sign in to comment.