MCPcopy Index your code
hub / github.com/bytebase/bytebase / CreateMaterializedView

Method CreateMaterializedView

backend/store/model/database.go:697–717  ·  view source on GitHub ↗

CreateMaterializedView creates a new materialized view in the schema. Returns an error if the materialized view already exists.

(viewName string, definition string)

Source from the content-addressed store, hash-verified

695// CreateMaterializedView creates a new materialized view in the schema.
696// Returns an error if the materialized view already exists.
697func (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.

Callers

nothing calls this directly

Calls 3

GetMaterializedViewMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected