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

Compare contract data types prior to creating the DDL with data types and constraints #708

Closed
wants to merge 2 commits into from

Conversation

dbeatty10
Copy link
Contributor

resolves #707

Problem

Users get an inscrutable error message if they forget to provide a data_type when enforcing a contract:

23:28:27  Unhandled error while executing 
'data_type'
23:28:27  1 of 1 ERROR creating sql table model dbt_dbeatty_tools.my_model ............... [ERROR in 0.07s]
23:28:28  
23:28:28  Finished running 1 table model in 0 hours 0 minutes and 3.88 seconds (3.88s).
23:28:28  
23:28:28  Completed with 1 error and 0 warnings:
23:28:28  
23:28:28    'data_type'

The root cause is that the order is accidentally backwards here.

It's supposed to be this before this:

    {{ get_assert_columns_equivalent(sql) }}
    {{ get_table_columns_and_constraints() }}

Solution

Flip the order!

To match the order in dbt-postgres, dbt-bigquery, and dbt-snowflake, just flip the order of these two lines:

{{ get_table_columns_and_constraints() }}
{{ get_assert_columns_equivalent(sql) }}

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)

@dbeatty10 dbeatty10 requested a review from a team as a code owner January 27, 2024 00:20
@cla-bot cla-bot bot added the cla:yes label Jan 27, 2024
@dbeatty10 dbeatty10 added ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering and removed cla:yes labels Jan 27, 2024
Copy link
Contributor

This PR has been marked as Stale because it has been open with no activity as of late. If you would like the PR to remain open, please comment on the PR or else it will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 25, 2024
Copy link
Contributor

github-actions bot commented Aug 1, 2024

Although we are closing this PR as stale, it can still be reopened to continue development. Just add a comment to notify the maintainers.

@github-actions github-actions bot closed this Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Unclear error message when a column in a contracted model is missing a data_type
1 participant