Skip to content

SQL-495: Convert the type system tables to catalog views - #40843

Open
SangJunBak wants to merge 7 commits into
jun/builtin-view-migrationfrom
jun/sql-495/type-relations
Open

SangJunBak wants to merge 7 commits into
jun/builtin-view-migrationfrom
jun/sql-495/type-relations

Conversation

@SangJunBak

@SangJunBak SangJunBak commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

See commit messages for details. These are quite simple builtin table conversions. We get the user custom types from the catalog and the rest statically from our list of builtins.

Motivation

Closes SQL-495

Verification

  • Diffed the type relations against what's currently on main
  • Added SLTs for verifying certain properties across our type relations

@SangJunBak
SangJunBak added this pull request to stack #40844 November 17, 2026 12:16
@linear-code

linear-code Bot commented Nov 17, 2026

Copy link
Copy Markdown

SQL-495

@SangJunBak
SangJunBak force-pushed the jun/sql-495/type-relations branch from da74c19 to 83a55e5 Compare November 18, 2026 07:41
@SangJunBak
SangJunBak removed this pull request from stack #40844 November 18, 2026 07:50
@SangJunBak
SangJunBak changed the base branch from jun/type-relations to jun/builtin-view-migration November 18, 2026 07:50
@SangJunBak
SangJunBak added this pull request to stack #40899 November 18, 2026 07:50
@SangJunBak
SangJunBak marked this pull request as ready for review November 18, 2026 07:50
@SangJunBak
SangJunBak requested review from a team as code owners November 18, 2026 07:50
@SangJunBak SangJunBak changed the title catalog: generate mz_builtin_types and stop packing type rows SQL-495: Convert the type system tables to catalog views Nov 18, 2026

@def- def- left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test changes lgtm

- Create mz_internal.mz_builtin_types to report builtin types. Essentially a move of the packing code from builtin_table_updates to make_builtin_types. The exception being....
- We extract `from_builtin_oid` from `name_from_oid` to get a mapping from a builtin catalog type to the pgwire typlen. We need `from_builtin_oid` since the builtin table way of getting the postgres type requires the catalog and SQLScalarTypes. This is because user types can be recursive. However our builtin types cannot be and we can use `from_builtin_oid`. To prevent drift, we add a test in catalog.rs that asserts `from_builtin_oid` against types via pgwire.
- Adds decoding code for user types
- Converts mz_types, mz_array_types, mz_base_types, mz_list_types, mz_map_types,
mz_pseudo_types and mz_type_pg_metadata to builtin views
- Creates tests for each builtin type relations such that it maintains parity with our previous builtin type relations
- Creates a test on `try_decode_catalog_create_sql` and assert how errors affect the relation
This is to test that types in the catalog are parsed successfully on upgrade. We add LIST and MAP types too, something that was missing from the original platform check.
In postgres, _record has a typlen of -1 rather than NULL and this was previously a bug. Because we use `from_oid` now, this corrects that behavior.
@SangJunBak
SangJunBak force-pushed the jun/sql-495/type-relations branch from a8161bd to 8f35c46 Compare November 19, 2026 00:43

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants