DropMaterializedView drops a materialized view from the schema. Returns an error if the materialized view does not exist.
(viewName string)
| 719 | // DropMaterializedView drops a materialized view from the schema. |
| 720 | // Returns an error if the materialized view does not exist. |
| 721 | func (s *SchemaMetadata) DropMaterializedView(viewName string) error { |
| 722 | // Check if materialized view exists |
| 723 | if s.GetMaterializedView(viewName) == nil { |
| 724 | return errors.Errorf("materialized view %q does not exist in schema %q", viewName, s.proto.Name) |
| 725 | } |
| 726 | |
| 727 | // Remove from internal map |
| 728 | viewID := normalizeNameByCaseSensitivity(viewName, s.isObjectCaseSensitive) |
| 729 | delete(s.internalMaterializedView, viewID) |
| 730 | |
| 731 | // Remove from proto's materialized view list |
| 732 | newViews := make([]*storepb.MaterializedViewMetadata, 0, len(s.proto.MaterializedViews)-1) |
| 733 | for _, view := range s.proto.MaterializedViews { |
| 734 | if s.isObjectCaseSensitive { |
| 735 | if view.Name != viewName { |
| 736 | newViews = append(newViews, view) |
| 737 | } |
| 738 | } else { |
| 739 | if !strings.EqualFold(view.Name, viewName) { |
| 740 | newViews = append(newViews, view) |
| 741 | } |
| 742 | } |
| 743 | } |
| 744 | s.proto.MaterializedViews = newViews |
| 745 | |
| 746 | return nil |
| 747 | } |
| 748 | |
| 749 | // DropMaterializedViewIndex drops an index from a materialized view. |
| 750 | func (s *SchemaMetadata) DropMaterializedViewIndex(viewName, indexName string) error { |
nothing calls this directly
no test coverage detected