Skip to content

Preserve plans on RENAME for MV / Index / CT#36145

Merged
ggevay merged 1 commit intoMaterializeInc:mainfrom
ggevay:fix-mv-rename-metainfo
Apr 21, 2026
Merged

Preserve plans on RENAME for MV / Index / CT#36145
ggevay merged 1 commit intoMaterializeInc:mainfrom
ggevay:fix-mv-rename-metainfo

Conversation

@ggevay
Copy link
Copy Markdown
Contributor

@ggevay ggevay commented Apr 19, 2026

Fixes https://github.com/MaterializeInc/database-issues/issues/11316

Since #35834 the optimized_plan, physical_plan, and dataflow_metainfo fields live on the CatalogItem itself rather than in the separate CatalogPlans side table. However, parse_item_inner hardcoded None for those fields when reconstructing a CatalogItem from create_sql. A RENAME on a materialized view (or index / continual task) goes through the retract+add path in apply_item_update, which calls deserialize_itemparse_itemparse_item_inner with the previous CatalogItem as previous_item. The plan fields would be silently dropped, so a subsequent EXPLAIN OPTIMIZED PLAN FOR MATERIALIZED VIEW ... would fail with "cannot find dataflow metainformation for materialized view ... in catalog".

Fix: carry the three plan fields from previous_item through to the newly-reconstructed item. This is done as a post-match stamp to avoid duplicating the logic into each of the three per-variant construction sites and to keep the change local.

(Note: I'm still planning to make the plans inside catalog items non-optional, as discussed here, so this is a temporary fix.)

@ggevay ggevay added the A-ADAPTER Topics related to the ADAPTER layer label Apr 19, 2026
@ggevay ggevay force-pushed the fix-mv-rename-metainfo branch from 6a4f4e2 to 722dfd2 Compare April 19, 2026 11:52
@ggevay ggevay marked this pull request as ready for review April 19, 2026 12:24
@ggevay ggevay requested a review from a team as a code owner April 19, 2026 12:24
@ggevay ggevay requested review from SangJunBak and mtabebe and removed request for SangJunBak April 19, 2026 12:24
Copy link
Copy Markdown
Contributor

@def- def- left a comment

Choose a reason for hiding this comment

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

The added tests lgtm, thanks for adding!

Since MaterializeInc#35834 the `optimized_plan`, `physical_plan`, and
`dataflow_metainfo` fields live on the `CatalogItem` itself rather
than in the separate `CatalogPlans` side table. However,
`parse_item_inner` hardcoded `None` for those fields when
reconstructing a `CatalogItem` from `create_sql`. A `RENAME` on a
materialized view (or index / continual task) goes through the
retract+add path in `apply_item_update`, which calls
`deserialize_item` → `parse_item` → `parse_item_inner` with the
previous `CatalogItem` as `previous_item`. The plan fields would be
silently dropped, so a subsequent `EXPLAIN OPTIMIZED PLAN FOR
MATERIALIZED VIEW ...` would fail with "cannot find dataflow
metainformation for materialized view ... in catalog".

Fix: carry the three plan fields from `previous_item` through to the
newly-reconstructed item. This is done as a post-match stamp to avoid
duplicating the logic into each of the three per-variant construction
sites and to keep the change local.

Also add a regression test to `test/sqllogictest/rename.slt` that
exercises `ALTER MATERIALIZED VIEW ... RENAME TO ...` and
`ALTER INDEX ... RENAME TO ...` followed by `EXPLAIN OPTIMIZED /
PHYSICAL PLAN`.

Co-authored-by: Junie <junie@jetbrains.com>
@ggevay ggevay force-pushed the fix-mv-rename-metainfo branch from 722dfd2 to 83050ba Compare April 20, 2026 13:23
Copy link
Copy Markdown
Contributor

@mtabebe mtabebe left a comment

Choose a reason for hiding this comment

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

Simple fix for the temporary problem. Thanks for the tests too

@ggevay ggevay merged commit 278f65f into MaterializeInc:main Apr 21, 2026
122 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ADAPTER Topics related to the ADAPTER layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants