CreateColumn creates a new column in the table. Returns an error if the column already exists.
(columnProto *storepb.ColumnMetadata, columnCatalog *storepb.ColumnCatalog)
| 973 | // CreateColumn creates a new column in the table. |
| 974 | // Returns an error if the column already exists. |
| 975 | func (t *TableMetadata) CreateColumn(columnProto *storepb.ColumnMetadata, columnCatalog *storepb.ColumnCatalog) error { |
| 976 | // Check if column already exists |
| 977 | if t.GetColumn(columnProto.Name) != nil { |
| 978 | return errors.Errorf("column %q already exists in table %q", columnProto.Name, t.proto.Name) |
| 979 | } |
| 980 | |
| 981 | // Add to proto's column list |
| 982 | t.proto.Columns = append(t.proto.Columns, columnProto) |
| 983 | |
| 984 | // Create ColumnMetadata wrapper and add to internal map |
| 985 | columnID := normalizeNameByCaseSensitivity(columnProto.Name, t.isDetailCaseSensitive) |
| 986 | t.internalColumn[columnID] = &ColumnMetadata{ |
| 987 | proto: columnProto, |
| 988 | config: columnCatalog, |
| 989 | } |
| 990 | |
| 991 | return nil |
| 992 | } |
| 993 | |
| 994 | // DropColumn drops a column from the table. |
| 995 | // Returns an error if the column does not exist. |