Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add
include_data_types
argument togenerate_model_yaml
macro #122Add
include_data_types
argument togenerate_model_yaml
macro #122Changes from 8 commits
0c3c737
e2f5b09
6acccf5
ad019b2
0de3eb7
12f21b4
4ff820a
43e7b7d
a76c139
f638309
1cebade
39b88ab
1e55d67
c1f5344
354865f
8320981
e61af4c
5e08a1a
b2f463c
09ba319
db521b2
d5aaa2b
8b4f258
2471363
c3abd44
6f6aea6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on the adapter / data platform, we may want this to be
column.dtype
instead ofcolumn.data_type
— I believe that will enable this to returntext
orvarchar
instead ofcharacter varying(1234)
.We could use the
dbt.format_column
macro, which is also what's used when doing the column type assertion for contracted models.If we do make this change, the
format_column
macro is new in v1.5, so this would require a version bump tocodegen
and to itsrequire-dbt-version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jtcohen6 good point about
column.dtype
vs.column.data_type
!Using
dbt.format_column
macroI like your idea of using the logic within the dbt.format_column macro. I think we should aim to preserve the wide range of
require-dbt-version: [">=1.0.0", "<2.0.0"]
though.There's multiple approaches we could take to use this logic into
codegen
without forcing an upgrade to 1.5.0. The quick'n'dirty option is to "vendor" it by just copy-pasting it into codegen. Another option is to inspect the dbt version, and fall back to a vendored version of the macro if it is less than 1.5.0.Difference between
dtype
anddata_type
My understanding of the difference between the two is
dtype
gives the database-specific data type with no size, scale, or precision (likevarchar
ordecimal
) whereasdata_type
is intended to give the database-specific data type with those included (likevarchar(80)
ordecimal(18, 2)
).Although dbt model contracts can operate with either input, it will effectively ignore any size/precision/scale that is supplied.
So best would be to exclude size/precision/scale to avoid any false impressions that it will be verified as part of the dbt model contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so I added this which I feel should work, but for some reason my tests fail locally because
formatted
is empty. My dbt version is1.5.0-b5
which is maybe pre-release and doesn't havedbt.format_columns
yet? If you have suggestions for getting around this please let me know, otherwise I can use the vendored version for everything.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbeatty10 @jtcohen6 any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dave-connors-3 @benmosher we may want to get this across the line now that generate model is live in the IDE. would be a good improvement to the functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, we may want to use
.dtype
instead of.data_type
, depending on the data platform — and theformat_column
macro (new in v1.5) could be our friend here.