-
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
adapter: correctly report custom types in mz_columns #27318
Conversation
.. | ||
} => { | ||
let entry = self.get_entry(custom_id); | ||
// NOTE(benesch): the `mz_columns.type text` field is |
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.
fwiw regtype
should resolve the OID to the right entry
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.
Yeah, and you can join mz_columns.type_oid
against mz_types.oid
by hand! It's just at odds with the rest of the mz_catalog
tables that you have to do the join with OID compatibility layer instead of being able to do it with Materialize's native global IDs.
Got a little spooked that no tests failed, so pushed up a new test file with some cases that would have failed before this change. |
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, @benesch!
For columns with a type of list, map, or record, the mz_columns table was incorrectly reporting the generic psuedotype for the column, even when the type was a named type in the catalog. For example, given the following objects: CREATE TYPE my_rec AS (x int, y int); CREATE TABLE my_tab (f1 my_rec); the mz_columns table would incorrectly report that column f1 had type record (OID 2249), rather than type my_rec with a dynamic OID determined at envd boot. This commit is a surgical fix that fixes the immediate issue. In the future, we may want to consider a deeper fix that makes the conversion between a `ScalarType` and a `pg_repr::Type` less prone to this sort of bug. That is a much larger refactor, however. We'll also want to deprecate `mz_columns.type` in the future, for the reasons noted in the comment in the patch. That too is left to future work for expediency.
For columns with a type of list, map, or record, the mz_columns table was incorrectly reporting the generic psuedotype for the column, even when the type was a named type in the catalog.
For example, given the following objects:
the mz_columns table would incorrectly report that column f1 had type record (OID 2249), rather than type my_rec with a dynamic OID determined at envd boot.
This commit is a surgical fix that fixes the immediate issue.
In the future, we may want to consider a deeper fix that makes the conversion between a
ScalarType
and apg_repr::Type
less prone to this sort of bug. That is a much larger refactor, however.We'll also want to deprecate
mz_columns.type
in the future, for the reasons noted in the comment in the patch. That too is left to future work for expediency.Motivation
This PR fixes a previously unreported bug.
This is preventing the dbt-materialize adapter from properly enforcing contracts against custom record, list, and map types.
Checklist
$T ⇔ Proto$T
mapping (possibly in a backwards-incompatible way), then it is tagged with aT-proto
label.mz_columns.type
andmz_columns.type_oid
when the column's type is a custom named record, list, or map. Previously, Materialize reported the generic psuedotype (record
,list
, ormap
, respectively); now Materialize reports the specific name of the custom named type.