cockroachdb / cockroachdb/cockroach

sql/schemachanger: implement REFRESH MATERIALIZED VIEW in the declarative schema changer

Open
#164,274 0 comments 0 reactions 0 assignees View on GitHub
A-schema-changer-impl C-enhancement T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

## Summary

`REFRESH MATERIALIZED VIEW` is needed alongside `CREATE MATERIALIZED VIEW WITH NO DATA` to populate view data. This depends on #164273 (CREATE MATERIALIZED VIEW).

## Describe the solution you'd like

- Add a new build handler for the `REFRESH MATERIALIZED VIEW` statement
- Handle the `CONCURRENTLY` option (refresh without locking reads)
- Handle the `WITH NO DATA` option (clear data without repopulating)
- Clear the `RefreshViewRequired` flag after a successful refresh
- Register in the `supportedStatements` map in `process.go`
- Add scbuild, scplan, and end-to-end logic tests

## Code References

- [refresh_materialized_view.go:26](https://github.com/cockroachdb/cockroach/blob/7f85419e8fa/pkg/sql/refresh_materialized_view.go#L26) — legacy `RefreshMaterializedView` implementation
- [process.go](https://github.com/cockroachdb/cockroach/blob/7f85419e8fa/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/process.go) — statement registration map

Epic: CRDB-31466

Jira issue: CRDB-60729

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.