Skip to content

Convert mz_columns and mz_index_columns to builtin mvs - #39427

Draft
SangJunBak wants to merge 13 commits into
jun/name-from-oidfrom
jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views
Draft

SangJunBak wants to merge 13 commits into
jun/name-from-oidfrom
jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views

Conversation

@SangJunBak

@SangJunBak SangJunBak commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Closes SQL-494

Description

What does this PR actually do? Focus on the approach and any non-obvious
decisions. The diff shows the code --- use this space to explain what the
diff can't tell a reviewer.

Verification

How do you know this change is correct? Describe new or existing automated
tests, or manual steps you took.

@linear-code

linear-code Bot commented Sep 30, 2026

Copy link
Copy Markdown

SQL-494

@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch from a659af0 to 27c8872 Compare October 6, 2026 19:49
@SangJunBak
SangJunBak changed the base branch from main to jun/sql-702/mv-refresh-strat October 6, 2026 19:56
@SangJunBak
SangJunBak added this pull request to stack #38849 October 6, 2026 19:56
@SangJunBak SangJunBak changed the title sql: extract plan_refresh_time from plan_create_materialized_view Refactor mz_columns and mz_index_columns Oct 7, 2026
@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch from 27c8872 to 7857df2 Compare October 9, 2026 15:29
@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch from 7857df2 to 3a32217 Compare October 9, 2026 15:34
@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch from 3a32217 to 27a429d Compare October 13, 2026 17:38
@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch from 27a429d to 3c03c63 Compare October 14, 2026 08:57
Base automatically changed from jun/sql-702/mv-refresh-strat to main October 14, 2026 10:25
@SangJunBak SangJunBak added the ci-nightly PR CI control: also trigger Nightly label Oct 14, 2026
@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch 4 times, most recently from 2194479 to ea159b9 Compare October 14, 2026 14:40
@SangJunBak
SangJunBak removed this pull request from stack #38849 October 14, 2026 14:41
@SangJunBak
SangJunBak changed the base branch from main to jun/durable-column October 14, 2026 14:41
@SangJunBak
SangJunBak added this pull request to stack #39819 October 14, 2026 14:41
@SangJunBak SangJunBak changed the title Refactor mz_columns and mz_index_columns Convert mz_columns and mz_index_columns to builtin mvs Oct 14, 2026
@SangJunBak
SangJunBak removed this pull request from stack #39819 October 15, 2026 19:41
@SangJunBak
SangJunBak changed the base branch from jun/durable-column to jun/name-from-oid October 15, 2026 19:42
@SangJunBak
SangJunBak added this pull request to stack #39878 October 15, 2026 19:42
@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch 2 times, most recently from 38b4832 to e10f1a1 Compare October 15, 2026 22:01
@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch from e10f1a1 to 35a9155 Compare October 16, 2026 20:28
@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch from 35a9155 to 55ffa2d Compare October 16, 2026 21:15
parse_catalog_create_sql reports a table's DEFAULT clauses by column name,
with the string 'NULL' for a column without one (matches current behavior),
so that mz_columns can read them. Non-table rows have the actual null value
for the default column.
@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch from 55ffa2d to 0b7ed13 Compare October 17, 2026 00:32
@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch from 0b7ed13 to f8af45f Compare October 17, 2026 00:48
SangJunBak and others added 12 commits October 16, 2026 21:09
The generated view lists the columns of every builtin relation, so that
catalog views can reference the column information of builtin items in
SQL.
mz_columns reads the ItemColumn rows each relation records in
mz_catalog_raw: the recorded OID and type modifier present the type through
mz_type_name, and a column of a CREATE TYPE list, map or record takes the
name and OID of that type's item instead. A table's column defaults are the
DEFAULT clauses of its create_sql, read through parse_catalog_create_sql.
Builtin relations' columns come from mz_builtin_columns, joined to the
builtin object mappings.

The packer goes away, and the relation gets a replacement migration step.

Part of SQL-494

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWJKdCnWF4iWnpNYVv3aRx
Plans, builtin object listings and OIDs change with mz_columns becoming a
materialized view and with the generated mz_builtin_columns view.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWJKdCnWF4iWnpNYVv3aRx
The sqllogictest pins the schema, the builtin, introspection and user rows
for every relation kind, and retraction. Its expectations were captured
from the builtin table before the conversion and hold for the view, except
that a table's defaults read as written.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWJKdCnWF4iWnpNYVv3aRx
The ItemColumns platform check creates tables, views, materialized views
and indexes with column and expression keys in every phase, adds columns
with ALTER TABLE, and comments on columns. It then checks what mz_columns
and mz_index_columns report and that the reported positions join with the
comments. In the upgrade scenarios the objects created before the upgrade
get their recorded rows from the bootstrap refresh.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWJKdCnWF4iWnpNYVv3aRx
mz_columns.slt asserts on allocated item ids and type OIDs and lists every
user object, which --auto-index-selects perturbs by creating wrapper views
and indexes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWJKdCnWF4iWnpNYVv3aRx
parse_catalog_create_sql reports an index's key expressions in index order,
so that mz_index_columns can read them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWJKdCnWF4iWnpNYVv3aRx
The generated view lists the key columns of every builtin index, so that
catalog views can reference them in SQL.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWJKdCnWF4iWnpNYVv3aRx
mz_index_columns reads the IndexColumn rows each index records, with the
key expressions as written in create_sql. Builtin and introspection source
index keys come from mz_builtin_index_columns, joined to the builtin index
mappings and to the per-cluster introspection source index records.

The packer goes away, and the relation gets a replacement migration step.

Closes: SQL-494

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWJKdCnWF4iWnpNYVv3aRx
…view

Plans, builtin object listings and OIDs change with mz_index_columns
becoming a materialized view and with the generated
mz_builtin_index_columns view.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWJKdCnWF4iWnpNYVv3aRx
The sqllogictest pins the builtin, introspection and user rows for every
key shape, and retraction. Its expectations were captured from the builtin
table before the conversion and hold for the view.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWJKdCnWF4iWnpNYVv3aRx
mz_index_columns.slt asserts on allocated item ids and lists every user
object, which --auto-index-selects perturbs by creating wrapper views and
indexes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWJKdCnWF4iWnpNYVv3aRx
@SangJunBak
SangJunBak force-pushed the jun/sql-494-convert-mz_columns-and-mz_index_columns-to-catalog-views branch from f8af45f to 3273714 Compare October 17, 2026 01:34

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

ci-nightly PR CI control: also trigger Nightly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant