feat: add location info when adding columns (#38)

This commit is contained in:
Zheming Li
2023-05-22 17:18:14 +08:00
committed by GitHub
parent f43972af48
commit 4204be285f
5 changed files with 4333 additions and 2658 deletions
+185 -43
View File
@@ -34,6 +34,52 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
type AddColumn_Location_LocationType int32
const (
AddColumn_Location_FIRST AddColumn_Location_LocationType = 0
AddColumn_Location_AFTER AddColumn_Location_LocationType = 1
)
// Enum value maps for AddColumn_Location_LocationType.
var (
AddColumn_Location_LocationType_name = map[int32]string{
0: "FIRST",
1: "AFTER",
}
AddColumn_Location_LocationType_value = map[string]int32{
"FIRST": 0,
"AFTER": 1,
}
)
func (x AddColumn_Location_LocationType) Enum() *AddColumn_Location_LocationType {
p := new(AddColumn_Location_LocationType)
*p = x
return p
}
func (x AddColumn_Location_LocationType) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (AddColumn_Location_LocationType) Descriptor() protoreflect.EnumDescriptor {
return file_greptime_v1_ddl_proto_enumTypes[0].Descriptor()
}
func (AddColumn_Location_LocationType) Type() protoreflect.EnumType {
return &file_greptime_v1_ddl_proto_enumTypes[0]
}
func (x AddColumn_Location_LocationType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use AddColumn_Location_LocationType.Descriptor instead.
func (AddColumn_Location_LocationType) EnumDescriptor() ([]byte, []int) {
return file_greptime_v1_ddl_proto_rawDescGZIP(), []int{9, 0, 0}
}
// "Data Definition Language" requests, that create, modify or delete the // "Data Definition Language" requests, that create, modify or delete the
// database structures but not the data. `DdlRequest` could carry more // database structures but not the data. `DdlRequest` could carry more
// information than plain SQL, for example, the "table_id" in `CreateTableExpr`. // information than plain SQL, for example, the "table_id" in `CreateTableExpr`.
@@ -753,6 +799,7 @@ type AddColumn struct {
ColumnDef *ColumnDef `protobuf:"bytes,1,opt,name=column_def,json=columnDef,proto3" json:"column_def,omitempty"` ColumnDef *ColumnDef `protobuf:"bytes,1,opt,name=column_def,json=columnDef,proto3" json:"column_def,omitempty"`
IsKey bool `protobuf:"varint,2,opt,name=is_key,json=isKey,proto3" json:"is_key,omitempty"` IsKey bool `protobuf:"varint,2,opt,name=is_key,json=isKey,proto3" json:"is_key,omitempty"`
Location *AddColumn_Location `protobuf:"bytes,3,opt,name=location,proto3" json:"location,omitempty"`
} }
func (x *AddColumn) Reset() { func (x *AddColumn) Reset() {
@@ -801,6 +848,13 @@ func (x *AddColumn) GetIsKey() bool {
return false return false
} }
func (x *AddColumn) GetLocation() *AddColumn_Location {
if x != nil {
return x.Location
}
return nil
}
type DropColumn struct { type DropColumn struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@@ -895,6 +949,61 @@ func (x *TableId) GetId() uint32 {
return 0 return 0
} }
type AddColumn_Location struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
LocationType AddColumn_Location_LocationType `protobuf:"varint,1,opt,name=location_type,json=locationType,proto3,enum=greptime.v1.AddColumn_Location_LocationType" json:"location_type,omitempty"`
AfterCloumnName string `protobuf:"bytes,2,opt,name=after_cloumn_name,json=afterCloumnName,proto3" json:"after_cloumn_name,omitempty"`
}
func (x *AddColumn_Location) Reset() {
*x = AddColumn_Location{}
if protoimpl.UnsafeEnabled {
mi := &file_greptime_v1_ddl_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddColumn_Location) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddColumn_Location) ProtoMessage() {}
func (x *AddColumn_Location) ProtoReflect() protoreflect.Message {
mi := &file_greptime_v1_ddl_proto_msgTypes[13]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddColumn_Location.ProtoReflect.Descriptor instead.
func (*AddColumn_Location) Descriptor() ([]byte, []int) {
return file_greptime_v1_ddl_proto_rawDescGZIP(), []int{9, 0}
}
func (x *AddColumn_Location) GetLocationType() AddColumn_Location_LocationType {
if x != nil {
return x.LocationType
}
return AddColumn_Location_FIRST
}
func (x *AddColumn_Location) GetAfterCloumnName() string {
if x != nil {
return x.AfterCloumnName
}
return ""
}
var File_greptime_v1_ddl_proto protoreflect.FileDescriptor var File_greptime_v1_ddl_proto protoreflect.FileDescriptor
var file_greptime_v1_ddl_proto_rawDesc = []byte{ var file_greptime_v1_ddl_proto_rawDesc = []byte{
@@ -1014,13 +1123,28 @@ var file_greptime_v1_ddl_proto_rawDesc = []byte{
0x73, 0x22, 0x33, 0x0a, 0x0b, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x22, 0x33, 0x0a, 0x0b, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65,
0x12, 0x24, 0x0a, 0x0e, 0x6e, 0x65, 0x77, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x12, 0x24, 0x0a, 0x0e, 0x6e, 0x65, 0x77, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6e, 0x61,
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x65, 0x77, 0x54, 0x61, 0x62, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x65, 0x77, 0x54, 0x61, 0x62,
0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x59, 0x0a, 0x09, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xc8, 0x02, 0x0a, 0x09, 0x41, 0x64, 0x64, 0x43, 0x6f,
0x75, 0x6d, 0x6e, 0x12, 0x35, 0x0a, 0x0a, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x64, 0x65, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x35, 0x0a, 0x0a, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x64,
0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x65, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74,
0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x44, 0x65, 0x66, 0x52, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x44, 0x65, 0x66,
0x09, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x44, 0x65, 0x66, 0x12, 0x15, 0x0a, 0x06, 0x69, 0x73, 0x52, 0x09, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x44, 0x65, 0x66, 0x12, 0x15, 0x0a, 0x06, 0x69,
0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x69, 0x73, 0x4b, 0x65, 0x73, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x69, 0x73, 0x4b,
0x79, 0x22, 0x20, 0x0a, 0x0a, 0x44, 0x72, 0x6f, 0x70, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x65, 0x79, 0x12, 0x3b, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2e,
0x76, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x2e, 0x4c, 0x6f, 0x63,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a,
0xaf, 0x01, 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x51, 0x0a, 0x0d,
0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0e, 0x32, 0x2c, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76,
0x31, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x2e, 0x4c, 0x6f, 0x63, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70,
0x65, 0x52, 0x0c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12,
0x2a, 0x0a, 0x11, 0x61, 0x66, 0x74, 0x65, 0x72, 0x5f, 0x63, 0x6c, 0x6f, 0x75, 0x6d, 0x6e, 0x5f,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x61, 0x66, 0x74, 0x65,
0x72, 0x43, 0x6c, 0x6f, 0x75, 0x6d, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x24, 0x0a, 0x0c, 0x4c,
0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x46,
0x49, 0x52, 0x53, 0x54, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x46, 0x54, 0x45, 0x52, 0x10,
0x01, 0x22, 0x20, 0x0a, 0x0a, 0x44, 0x72, 0x6f, 0x70, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12,
0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x22, 0x19, 0x0a, 0x07, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x49, 0x64, 0x12, 0x0e, 0x61, 0x6d, 0x65, 0x22, 0x19, 0x0a, 0x07, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x49, 0x64, 0x12, 0x0e,
0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x42, 0x4c, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x42, 0x4c,
@@ -1044,43 +1168,48 @@ func file_greptime_v1_ddl_proto_rawDescGZIP() []byte {
return file_greptime_v1_ddl_proto_rawDescData return file_greptime_v1_ddl_proto_rawDescData
} }
var file_greptime_v1_ddl_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_greptime_v1_ddl_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_greptime_v1_ddl_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_greptime_v1_ddl_proto_goTypes = []interface{}{ var file_greptime_v1_ddl_proto_goTypes = []interface{}{
(*DdlRequest)(nil), // 0: greptime.v1.DdlRequest (AddColumn_Location_LocationType)(0), // 0: greptime.v1.AddColumn.Location.LocationType
(*CreateTableExpr)(nil), // 1: greptime.v1.CreateTableExpr (*DdlRequest)(nil), // 1: greptime.v1.DdlRequest
(*AlterExpr)(nil), // 2: greptime.v1.AlterExpr (*CreateTableExpr)(nil), // 2: greptime.v1.CreateTableExpr
(*DropTableExpr)(nil), // 3: greptime.v1.DropTableExpr (*AlterExpr)(nil), // 3: greptime.v1.AlterExpr
(*FlushTableExpr)(nil), // 4: greptime.v1.FlushTableExpr (*DropTableExpr)(nil), // 4: greptime.v1.DropTableExpr
(*CreateDatabaseExpr)(nil), // 5: greptime.v1.CreateDatabaseExpr (*FlushTableExpr)(nil), // 5: greptime.v1.FlushTableExpr
(*AddColumns)(nil), // 6: greptime.v1.AddColumns (*CreateDatabaseExpr)(nil), // 6: greptime.v1.CreateDatabaseExpr
(*DropColumns)(nil), // 7: greptime.v1.DropColumns (*AddColumns)(nil), // 7: greptime.v1.AddColumns
(*RenameTable)(nil), // 8: greptime.v1.RenameTable (*DropColumns)(nil), // 8: greptime.v1.DropColumns
(*AddColumn)(nil), // 9: greptime.v1.AddColumn (*RenameTable)(nil), // 9: greptime.v1.RenameTable
(*DropColumn)(nil), // 10: greptime.v1.DropColumn (*AddColumn)(nil), // 10: greptime.v1.AddColumn
(*TableId)(nil), // 11: greptime.v1.TableId (*DropColumn)(nil), // 11: greptime.v1.DropColumn
nil, // 12: greptime.v1.CreateTableExpr.TableOptionsEntry (*TableId)(nil), // 12: greptime.v1.TableId
(*ColumnDef)(nil), // 13: greptime.v1.ColumnDef nil, // 13: greptime.v1.CreateTableExpr.TableOptionsEntry
(*AddColumn_Location)(nil), // 14: greptime.v1.AddColumn.Location
(*ColumnDef)(nil), // 15: greptime.v1.ColumnDef
} }
var file_greptime_v1_ddl_proto_depIdxs = []int32{ var file_greptime_v1_ddl_proto_depIdxs = []int32{
5, // 0: greptime.v1.DdlRequest.create_database:type_name -> greptime.v1.CreateDatabaseExpr 6, // 0: greptime.v1.DdlRequest.create_database:type_name -> greptime.v1.CreateDatabaseExpr
1, // 1: greptime.v1.DdlRequest.create_table:type_name -> greptime.v1.CreateTableExpr 2, // 1: greptime.v1.DdlRequest.create_table:type_name -> greptime.v1.CreateTableExpr
2, // 2: greptime.v1.DdlRequest.alter:type_name -> greptime.v1.AlterExpr 3, // 2: greptime.v1.DdlRequest.alter:type_name -> greptime.v1.AlterExpr
3, // 3: greptime.v1.DdlRequest.drop_table:type_name -> greptime.v1.DropTableExpr 4, // 3: greptime.v1.DdlRequest.drop_table:type_name -> greptime.v1.DropTableExpr
4, // 4: greptime.v1.DdlRequest.flush_table:type_name -> greptime.v1.FlushTableExpr 5, // 4: greptime.v1.DdlRequest.flush_table:type_name -> greptime.v1.FlushTableExpr
13, // 5: greptime.v1.CreateTableExpr.column_defs:type_name -> greptime.v1.ColumnDef 15, // 5: greptime.v1.CreateTableExpr.column_defs:type_name -> greptime.v1.ColumnDef
12, // 6: greptime.v1.CreateTableExpr.table_options:type_name -> greptime.v1.CreateTableExpr.TableOptionsEntry 13, // 6: greptime.v1.CreateTableExpr.table_options:type_name -> greptime.v1.CreateTableExpr.TableOptionsEntry
11, // 7: greptime.v1.CreateTableExpr.table_id:type_name -> greptime.v1.TableId 12, // 7: greptime.v1.CreateTableExpr.table_id:type_name -> greptime.v1.TableId
6, // 8: greptime.v1.AlterExpr.add_columns:type_name -> greptime.v1.AddColumns 7, // 8: greptime.v1.AlterExpr.add_columns:type_name -> greptime.v1.AddColumns
7, // 9: greptime.v1.AlterExpr.drop_columns:type_name -> greptime.v1.DropColumns 8, // 9: greptime.v1.AlterExpr.drop_columns:type_name -> greptime.v1.DropColumns
8, // 10: greptime.v1.AlterExpr.rename_table:type_name -> greptime.v1.RenameTable 9, // 10: greptime.v1.AlterExpr.rename_table:type_name -> greptime.v1.RenameTable
9, // 11: greptime.v1.AddColumns.add_columns:type_name -> greptime.v1.AddColumn 10, // 11: greptime.v1.AddColumns.add_columns:type_name -> greptime.v1.AddColumn
10, // 12: greptime.v1.DropColumns.drop_columns:type_name -> greptime.v1.DropColumn 11, // 12: greptime.v1.DropColumns.drop_columns:type_name -> greptime.v1.DropColumn
13, // 13: greptime.v1.AddColumn.column_def:type_name -> greptime.v1.ColumnDef 15, // 13: greptime.v1.AddColumn.column_def:type_name -> greptime.v1.ColumnDef
14, // [14:14] is the sub-list for method output_type 14, // 14: greptime.v1.AddColumn.location:type_name -> greptime.v1.AddColumn.Location
14, // [14:14] is the sub-list for method input_type 0, // 15: greptime.v1.AddColumn.Location.location_type:type_name -> greptime.v1.AddColumn.Location.LocationType
14, // [14:14] is the sub-list for extension type_name 16, // [16:16] is the sub-list for method output_type
14, // [14:14] is the sub-list for extension extendee 16, // [16:16] is the sub-list for method input_type
0, // [0:14] is the sub-list for field type_name 16, // [16:16] is the sub-list for extension type_name
16, // [16:16] is the sub-list for extension extendee
0, // [0:16] is the sub-list for field type_name
} }
func init() { file_greptime_v1_ddl_proto_init() } func init() { file_greptime_v1_ddl_proto_init() }
@@ -1234,6 +1363,18 @@ func file_greptime_v1_ddl_proto_init() {
return nil return nil
} }
} }
file_greptime_v1_ddl_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddColumn_Location); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
file_greptime_v1_ddl_proto_msgTypes[0].OneofWrappers = []interface{}{ file_greptime_v1_ddl_proto_msgTypes[0].OneofWrappers = []interface{}{
(*DdlRequest_CreateDatabase)(nil), (*DdlRequest_CreateDatabase)(nil),
@@ -1253,13 +1394,14 @@ func file_greptime_v1_ddl_proto_init() {
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_greptime_v1_ddl_proto_rawDesc, RawDescriptor: file_greptime_v1_ddl_proto_rawDesc,
NumEnums: 0, NumEnums: 1,
NumMessages: 13, NumMessages: 14,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },
GoTypes: file_greptime_v1_ddl_proto_goTypes, GoTypes: file_greptime_v1_ddl_proto_goTypes,
DependencyIndexes: file_greptime_v1_ddl_proto_depIdxs, DependencyIndexes: file_greptime_v1_ddl_proto_depIdxs,
EnumInfos: file_greptime_v1_ddl_proto_enumTypes,
MessageInfos: file_greptime_v1_ddl_proto_msgTypes, MessageInfos: file_greptime_v1_ddl_proto_msgTypes,
}.Build() }.Build()
File_greptime_v1_ddl_proto = out.File File_greptime_v1_ddl_proto = out.File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+10
View File
@@ -90,6 +90,16 @@ message RenameTable { string new_table_name = 1; }
message AddColumn { message AddColumn {
ColumnDef column_def = 1; ColumnDef column_def = 1;
bool is_key = 2; bool is_key = 2;
message Location {
enum LocationType {
FIRST = 0;
AFTER = 1;
}
LocationType location_type = 1;
string after_cloumn_name = 2;
}
Location location = 3;
} }
message DropColumn { string name = 1; } message DropColumn { string name = 1; }