Skip to content

[BugFix] Restore SHOW CREATE MATERIALIZED VIEW for sync MVs (backport #73396)#73493

Merged
wanpengfei-git merged 3 commits into
branch-4.0from
mergify/bp/branch-4.0/pr-73396
May 19, 2026
Merged

[BugFix] Restore SHOW CREATE MATERIALIZED VIEW for sync MVs (backport #73396)#73493
wanpengfei-git merged 3 commits into
branch-4.0from
mergify/bp/branch-4.0/pr-73396

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented May 19, 2026

Sync MVs are mv indexes inside an OLAP table and are not registered as separate Tables in Database.idToTable / nameToTable. Since #43162 ("temporary table part-1") replaced the lookup in
showCreateInternalCatalogTable with MetaUtils.getSessionAwareTable, which throws SemanticException on miss, the existing fallback that scanned OLAP tables for a matching mv index has been unreachable - SHOW CREATE MATERIALIZED VIEW <sync_mv> has been failing with "Table ... is not found".

Catch SemanticException from the lookup and route MV-typed queries to a new findSyncMaterializedViewCreateStmt helper that performs the scan under DB READ (the indexNameToMetaId / indexMetaIdToMeta maps are HashMap-backed and mutated by ALTER, so the scan needs DB-wide exclusion). Non-MV queries rethrow the original "table not found" error unchanged.

Why I'm doing:

What I'm doing:

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
    • This pr needs auto generate documentation
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.1
    • 4.0
    • 3.5
    • 3.4

This is an automatic backport of pull request #73396 done by [Mergify](https://mergify.com).

Signed-off-by: Kevin Cai <kevin.cai@celerdata.com>
(cherry picked from commit 4e35d9d)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java
@mergify mergify Bot added the conflicts label May 19, 2026
@mergify
Copy link
Copy Markdown
Contributor Author

mergify Bot commented May 19, 2026

Cherry-pick of 4e35d9d has failed:

On branch mergify/bp/branch-4.0/pr-73396
Your branch is up to date with 'origin/branch-4.0'.

You are currently cherry-picking commit 4e35d9dc26.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   fe/fe-core/src/test/java/com/starrocks/catalog/MaterializedViewTest.java
	new file:   test/sql/test_materialized_view/R/test_show_create_sync_materialized_view
	new file:   test/sql/test_materialized_view/T/test_show_create_sync_materialized_view

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@wanpengfei-git wanpengfei-git enabled auto-merge (squash) May 19, 2026 09:28
@mergify mergify Bot closed this May 19, 2026
auto-merge was automatically disabled May 19, 2026 09:28

Pull request was closed

@mergify
Copy link
Copy Markdown
Contributor Author

mergify Bot commented May 19, 2026

@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr

@kevincai kevincai reopened this May 19, 2026
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) May 19, 2026 09:30
@kevincai
Copy link
Copy Markdown
Contributor

@copilot help to resolve the backport code conflict in single commit.

Agent-Logs-Url: https://github.com/StarRocks/starrocks/sessions/69524445-236d-4fa9-8751-e5687e623fb6

Co-authored-by: kevincai <771299+kevincai@users.noreply.github.com>
auto-merge was automatically disabled May 19, 2026 09:44

Head branch was pushed to by a user without write access

Agent-Logs-Url: https://github.com/StarRocks/starrocks/sessions/69524445-236d-4fa9-8751-e5687e623fb6

Co-authored-by: kevincai <771299+kevincai@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

@copilot help to resolve the backport code conflict in single commit.

Resolved the backport conflict in ShowExecutor and fixed the related test compile issue on branch-4.0; targeted FE validation is passing on 2a720f0.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from kevincai May 19, 2026 09:50
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) May 19, 2026 09:54
@wanpengfei-git wanpengfei-git merged commit c9c480d into branch-4.0 May 19, 2026
28 checks passed
@wanpengfei-git wanpengfei-git deleted the mergify/bp/branch-4.0/pr-73396 branch May 19, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants