-
Notifications
You must be signed in to change notification settings - Fork 55
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
fix: correctly handle unbound varchar case instead of defaulting to varchar(256) #194
Conversation
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.
Thanks for opening this PR. It looks good to me.
Let me know if there's some place to easily add in tests for this sort of case and I can do that.
@mdesmet @damian3031 do we test union_relations
macro?
Reading the comment here makes me think there is another bug, it could also be that other dbms always return a bounded varchar.
|
the integration tests for union_relations are here: We don't test this particular case however where all columns are unbounded and then converted into |
In case of a UNION with unbounded |
Since we haven't overidden We could override the We can override just the Let me know your thoughts on setting an unbound
This repo doesn't require |
@kalvinnchau: I checked the other connectors and seems it is safe to set it to the max VARCHAR length of Trino. Let's do that. Let's not add dbt-utils to dbt-trino. Maybe we can simply add some integration tests where we assert that an unbounded VARCHAR returns the max VARCHAR length? |
set the string_size of an unbound varchar to max length of a varchar add some unit tests to cover the bound and unbound varchar parsing
@mdesmet I've overridden the Also added a |
Overview
This is related to #35, the linked issue listed two separate issues, and one was already resolved.
Now that the dbt-core PR has been merged, we can use the
TrinoColumn
class to handle the hard-coded256
, the super class implementation still checks ifchar_size is None
and sets it to256
if is it `None.https://github.com/dbt-labs/dbt-core/blob/0544b085439b3a635b8ce56adbf56d8e7c7e6839/core/dbt/adapters/base/column.py#L86-L94
In dbt_utils.union_relations it uses the
col.data_type
property to get the typehttps://github.com/dbt-labs/dbt-utils/blob/84cf0f2971f5bf539b06c42373a5e80b59ba7047/macros/sql/union.sql#L102-L111
Given two tables:
The
dbt_utils.union_relations
macro currently produces:This change allows the
dbt_utils.union_relations
to produce the expected output of:Let me know if there's some place to easily add in tests for this sort of case and I can do that.
Checklist
README.md
updated and added information about my changechangie new
to create a changelog entry