feat: distributed alter table in region server (#97)

* feat: alter region request
This commit is contained in:
LFC
2023-09-04 18:58:35 +08:00
committed by GitHub
parent b585955dbb
commit 1969b5d610
14 changed files with 10367 additions and 5386 deletions
-8
View File
@@ -67,14 +67,6 @@ enum SemanticType {
TIMESTAMP = 2;
}
// TODO: deprecate this, and use the `ColumnDef` in region_server.proto instead
message ColumnDef {
string name = 1;
ColumnDataType datatype = 2;
bool is_nullable = 3;
bytes default_constraint = 4;
}
enum ColumnDataType {
BOOLEAN = 0;
INT8 = 1;
+18 -14
View File
@@ -60,9 +60,6 @@ message AlterExpr {
DropColumns drop_columns = 5;
RenameTable rename_table = 6;
}
TableId table_id = 7;
// table version before altering.
uint64 table_version = 8;
}
message DropTableExpr {
@@ -93,19 +90,26 @@ message RenameTable { string new_table_name = 1; }
message AddColumn {
ColumnDef column_def = 1;
bool is_key = 2;
message Location {
enum LocationType {
FIRST = 0;
AFTER = 1;
}
LocationType location_type = 1;
string after_column_name = 2;
}
Location location = 3;
AddColumnLocation location = 3;
}
message DropColumn { string name = 1; }
message TableId { uint32 id = 1; }
message ColumnDef {
string name = 1;
ColumnDataType data_type = 2;
bool is_nullable = 3;
bytes default_constraint = 4;
SemanticType semantic_type = 5;
}
message AddColumnLocation {
enum LocationType {
FIRST = 0;
AFTER = 1;
}
LocationType location_type = 1;
string after_column_name = 2;
}
+33 -9
View File
@@ -22,6 +22,7 @@ option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1/regio
import "greptime/v1/common.proto";
import "greptime/v1/row.proto";
import "greptime/v1/ddl.proto";
service Region { rpc Handle(RegionRequest) returns (RegionResponse); }
@@ -78,7 +79,7 @@ message CreateRequest {
// Region engine name
string engine = 2;
// Columns in this region.
repeated ColumnDef column_defs = 3;
repeated RegionColumnDef column_defs = 3;
// Column Id of primary keys.
repeated uint32 primary_key = 4;
// Create region if not exists.
@@ -110,18 +111,41 @@ message OpenRequest {
message CloseRequest { uint64 region_id = 1; }
// TODO: implement alter request
message AlterRequest { uint64 region_id = 1; }
message AlterRequest {
uint64 region_id = 1;
oneof kind {
AddColumns add_columns = 2;
DropColumns drop_columns = 3;
}
// The version of the schema before applying the alteration.
uint64 schema_version = 4;
}
message AddColumns {
repeated AddColumn add_columns = 1;
}
message DropColumns {
repeated DropColumn drop_columns = 1;
}
message AddColumn {
RegionColumnDef column_def = 1;
AddColumnLocation location = 3;
}
message DropColumn {
string name = 1;
}
message FlushRequest { uint64 region_id = 1; }
message CompactRequest { uint64 region_id = 1; }
message ColumnDef {
string name = 1;
// The column definition of a region. Unlike the message `ColumnDef` in `ddl.proto` which is for clients outside
// GreptimeDB, this `RegionColumnDef` is for region requests use only. So it carries an extra field `column_id` that
// is known internally.
message RegionColumnDef {
ColumnDef column_def = 1;
uint32 column_id = 2;
ColumnDataType datatype = 3;
bool is_nullable = 4;
bytes default_constraint = 5;
SemanticType semantic_type = 6;
}