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

Model contracts: raise warning for numeric types without specified scale #8721

Merged
merged 6 commits into from
Sep 27, 2023

Conversation

emmyoop
Copy link
Member

@emmyoop emmyoop commented Sep 26, 2023

resolves #8183

Problem

Enforces contracts with numeric types that don't specify scale run the risk of failing contract enforcement. This is actually confusing as they're not actually intentionally failing, the precision just needs to be specified so it can be enforced instead of applying the default.

Solution

If the user has provided a numeric data type, which should specify precision/scale, without having specified anything except the type, raise a warning.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@cla-bot cla-bot bot added the cla:yes label Sep 26, 2023
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (7b02bd1) 86.65% compared to head (c6d4875) 86.66%.
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8721   +/-   ##
=======================================
  Coverage   86.65%   86.66%           
=======================================
  Files         176      176           
  Lines       25674    25765   +91     
=======================================
+ Hits        22248    22329   +81     
- Misses       3426     3436   +10     
Flag Coverage Δ
integration 83.50% <ø> (+0.02%) ⬆️
unit 65.13% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 11 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@emmyoop emmyoop marked this pull request as ready for review September 26, 2023 19:22
@emmyoop emmyoop requested review from a team as code owners September 26, 2023 19:22
Copy link
Contributor

@colin-rogers-dbt colin-rogers-dbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some nits otherwise LGTM

.changes/unreleased/Features-20230926-134728.yaml Outdated Show resolved Hide resolved
@emmyoop emmyoop merged commit 556fad5 into main Sep 27, 2023
50 checks passed
@emmyoop emmyoop deleted the er/8183-numeric-scales branch September 27, 2023 13:00
QMalcolm pushed a commit that referenced this pull request Oct 9, 2023
…ale (#8721)

* add warning when contracting fields don't have precision

* rename files

* changelog

* move tests out of adapter zone

* Update core/dbt/include/global_project/macros/adapters/columns.sql

Co-authored-by: colin-rogers-dbt <[email protected]>

* Apply suggestions from code review

---------

Co-authored-by: colin-rogers-dbt <[email protected]>
@jtcohen6 jtcohen6 added the user docs [docs.getdbt.com] Needs better documentation label Oct 11, 2023
@FishtownBuildBot
Copy link
Collaborator

Opened a new issue in dbt-labs/docs.getdbt.com: dbt-labs/docs.getdbt.com#4251

runleonarun added a commit to dbt-labs/docs.getdbt.com that referenced this pull request Oct 11, 2023
…view) (#4258)

closes #4251

Captures this Core change:
dbt-labs/dbt-core#8721

This PR adds more context for rules, adds an example, and notes that
core includes an error for 1.7 and higher.

Note: This PR reverts #4257 which reverted
#4255

---------

Co-authored-by: Emily Rockman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes user docs [docs.getdbt.com] Needs better documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-2857] Model contracts: raise warning for numeric types without specified scale
5 participants