-
Notifications
You must be signed in to change notification settings - Fork 465
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
dbt-materialize: more gracefully handle contracts on unknown types #23953
dbt-materialize: more gracefully handle contracts on unknown types #23953
Conversation
61372de
to
da66fd7
Compare
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 again for tying this up in a bow, @benesch!
misc/dbt-materialize/CHANGELOG.md
Outdated
* Backport [dbt-core #8887](https://github.com/dbt-labs/dbt-core/pull/8887) to | ||
to unblock users using any custom type with data contracts. |
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.
* Backport [dbt-core #8887](https://github.com/dbt-labs/dbt-core/pull/8887) to | |
to unblock users using any custom type with data contracts. | |
* Backport [dbt-core #8887](https://github.com/dbt-labs/dbt-core/pull/8887) to | |
unblock users using any custom type with data contracts. |
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.
Oops, thanks!
@@ -31,6 +32,12 @@ | |||
|
|||
logger = AdapterLogger("Materialize") | |||
|
|||
# NOTE(morsapaes): registering the UUID type produces nicer error messages |
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.
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.
🫡
@@ -31,6 +32,12 @@ | |||
|
|||
logger = AdapterLogger("Materialize") | |||
|
|||
# NOTE(morsapaes): registering the UUID type produces nicer error messages | |||
# when data contracts fail on a UUID type. See comment in the | |||
# `data_type_code_to_name`` method for details. We may be able to remove |
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.
# `data_type_code_to_name`` method for details. We may be able to remove | |
# `data_type_code_to_name` method for details. We may be able to remove |
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, fixed.
Backport dbt-labs/dbt-core#8887 to make data contracts work correctly with custom PostgreSQL types that are unknown to dbt/psycopg2. The error messages are bad when contract validation on such types fails, but the contracts fundamentally work, which is a big improvement. See comments within the patch for details.
da66fd7
to
e837a48
Compare
Unfortunately, this patch doesn't generalize due to MaterializeInc/database-issues#5211. After fetching the columns and data types for the query in the model, dbt will also fetch the columns and data types declared in the cast(null as {{ col['data_type'] }}) as {{ col_name }}{{ ", " if not loop.last }} This will result in a create temporary view __dbt_sbq19 as
select * from (
select
cast(null as record) as rd
) as __dbt_sbq I'll work on a patch to the patch, but wanted to raise in the meantime so we don't point users with this issue at v1.7.2. |
Hrm, what's the workaround though? It seems like we might just need to fix this one Materialize side. The way we handle casts to |
I was trying to think of something smart, but...is it easy enough a fix that we could ship it in the next release? |
Probably not. Lemme start a Slack conversation. |
For posterity, Slack conversation here: https://materializeinc.slack.com/archives/C0414ER457U/p1702931272032539 |
Backport dbt-labs/dbt-core#8887 to make data contracts work correctly with custom PostgreSQL types that are unknown to dbt/psycopg2. The error messages are bad when contract validation on such types fails, but the contracts fundamentally work, which is a big improvement.
See comments within the patch for details.
Motivation
Checklist
$T ⇔ Proto$T
mapping (possibly in a backwards-incompatible way), then it is tagged with aT-proto
label.