Skip to content

SQL-495: Convert the function system tables to catalog views - #40900

Draft
SangJunBak wants to merge 10 commits into
jun/sql-495/type-relationsfrom
jun/function-relations
Draft

SangJunBak wants to merge 10 commits into
jun/sql-495/type-relationsfrom
jun/function-relations

Conversation

@SangJunBak

@SangJunBak SangJunBak commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

See commit messages for details. These are quite simple builtin table conversions. Since none use the catalog, 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 changed the title catalog: define the function and operator relations as views SQL-496: convert function and operator relations builtin tables Nov 18, 2026
@SangJunBak
SangJunBak added this pull request to stack #40899 November 18, 2026 07:57
@SangJunBak
SangJunBak force-pushed the jun/function-relations branch from 80fcf1c to 48b2111 Compare November 18, 2026 22:01
SangJunBak and others added 10 commits November 18, 2026 17:44
- 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
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.
mz_functions, mz_operators and mz_aggregates were builtin tables packed
by the adapter from the function registry at every catalog open. They
are now views over the generated mz_internal.mz_builtin_functions and
mz_internal.mz_builtin_operators views, one row per implementation,
with the type names of a signature resolved to catalog ids through
mz_builtin_object_mappings. pack_item_update no longer packs rows for
functions, catalog open no longer packs a row per operator, and the
builtin version pin records the conversion, as does a Replacement step
per relation in MIGRATIONS. pg_aggregate declares the oid key it now
derives through mz_aggregates.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>


resolve rebase conflicts: catalog: define the function and operator relations as views
mz_functions, mz_operators and mz_aggregates became views, so a Drop step
at the conversion version sends each of their shards to finalization.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The catalog changes below this one leave every generated test output at
its main version. This change holds all of them for the stack: the
sqllogictest goldens listing builtin objects, their OIDs, columns and
catalog server plans, the two error messages that list the available
relations, and the scalar function registry and LIR snapshots.

    ci/test/lint-docs-catalog.py
    bin/sqllogictest -- --rewrite-results <files>
    REWRITE=1 cargo test -p mz-compute-types --test func_registry
    REWRITE=1 cargo test -p mz-compute-types --test lir_schema

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
mz_functions, mz_operators and mz_aggregates are views now, and the two
generated views they read, mz_builtin_functions and mz_builtin_operators,
are new builtins. That adds five EXPLAIN queries to
catalog_server_explain.slt, flips the three relations to VIEW in
information_schema_tables.slt, lists the new views in the autogenerated
mz_internal.slt and oid.slt, and shifts the catalog server index ids by
two. The func_registry and lir_schema snapshots are unchanged.

    ci/test/lint-docs-catalog.py
    bin/sqllogictest -- --rewrite-results <files>
    REWRITE=1 cargo test -p mz-compute-types --test func_registry --test lir_schema

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>


resolve rebase conflicts: test: regenerate the goldens for the function relation views

resolve rebase conflicts: test: regenerate the goldens for the function relation views
@SangJunBak
SangJunBak force-pushed the jun/function-relations branch from 48b2111 to 1023d89 Compare November 18, 2026 23:01
@SangJunBak SangJunBak changed the title SQL-496: convert function and operator relations builtin tables SQL-495: Convert the function system tables to catalog views Nov 18, 2026
@linear-code

linear-code Bot commented Nov 18, 2026

Copy link
Copy Markdown

SQL-495

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.

1 participant