CreateMaterializedView creates a new materialized view in the schema. Returns an error if the materialized view already exists.
(viewName string, definition string)
| 695 | // CreateMaterializedView creates a new materialized view in the schema. |
| 696 | // Returns an error if the materialized view already exists. |
| 697 | func (s *SchemaMetadata) CreateMaterializedView(viewName string, definition string) (*storepb.MaterializedViewMetadata, error) { |
| 698 | // Check if materialized view already exists |
| 699 | if s.GetMaterializedView(viewName) != nil { |
| 700 | return nil, errors.Errorf("materialized view %q already exists in schema %q", viewName, s.proto.Name) |
| 701 | } |
| 702 | |
| 703 | // Create new materialized view proto |
| 704 | newViewProto := &storepb.MaterializedViewMetadata{ |
| 705 | Name: viewName, |
| 706 | Definition: definition, |
| 707 | } |
| 708 | |
| 709 | // Add to proto's materialized view list |
| 710 | s.proto.MaterializedViews = append(s.proto.MaterializedViews, newViewProto) |
| 711 | |
| 712 | // Add to internal map |
| 713 | viewID := normalizeNameByCaseSensitivity(viewName, s.isObjectCaseSensitive) |
| 714 | s.internalMaterializedView[viewID] = newViewProto |
| 715 | |
| 716 | return newViewProto, nil |
| 717 | } |
| 718 | |
| 719 | // DropMaterializedView drops a materialized view from the schema. |
| 720 | // Returns an error if the materialized view does not exist. |
nothing calls this directly
no test coverage detected