Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backupccl: support materialized view mutation in restore #102516

Merged
merged 1 commit into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/ccl/backupccl/restore_schema_change_creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func jobDescriptionFromMutationID(
}
}
jobDescBuilder.WriteString(")")
case *descpb.DescriptorMutation_MaterializedViewRefresh:
jobDescBuilder.WriteString("refreshing materialized view with primary key ")
jobDescBuilder.WriteString(t.MaterializedViewRefresh.NewPrimaryIndex.Name)
default:
return "", 0, errors.Newf("unsupported mutation %+v, while restoring table %+v", m, tableDesc)
}
Expand Down
42 changes: 42 additions & 0 deletions pkg/ccl/backupccl/testdata/backup-restore/materialized_view
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# We allow implicit access to non-admin users so that we can test
# with nodelocal.
new-cluster name=s1 allow-implicit-access
----

exec-sql
CREATE DATABASE testdb;
USE testdb;
CREATE TABLE testdb.t (a int primary key, b int);
CREATE MATERIALIZED VIEW testdb.mv AS SELECT a, b FROM testdb.t;
INSERT INTO testdb.t (a, b) VALUES (1, 2);
----

exec-sql
REFRESH MATERIALIZED VIEW mv;
----

exec-sql
INSERT INTO testdb.t (a, b) VALUES (2, 3);
----

exec-sql
REFRESH MATERIALIZED VIEW mv;
----

exec-sql
BACKUP INTO 'nodelocal://1/test/'
----


new-cluster name=s2 share-io-dir=s1 allow-implicit-access
----

exec-sql
RESTORE DATABASE testdb FROM LATEST IN 'nodelocal://1/test/' WITH new_db_name = 'newdb';
----

query-sql
SELECT * FROM newdb.mv;
----
1 2
2 3