112 lines
2.8 KiB
Protocol Buffer
112 lines
2.8 KiB
Protocol Buffer
// Copyright 2023 Greptime Team
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
syntax = "proto3";
|
|
|
|
package greptime.v1;
|
|
|
|
option java_package = "io.greptime.v1";
|
|
option java_outer_classname = "Ddl";
|
|
option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1";
|
|
|
|
import "greptime/v1/common.proto";
|
|
|
|
// "Data Definition Language" requests, that create, modify or delete the
|
|
// database structures but not the data. `DdlRequest` could carry more
|
|
// information than plain SQL, for example, the "table_id" in `CreateTableExpr`.
|
|
// So create a new DDL expr if you need it.
|
|
message DdlRequest {
|
|
oneof expr {
|
|
CreateDatabaseExpr create_database = 1;
|
|
CreateTableExpr create_table = 2;
|
|
AlterExpr alter = 3;
|
|
DropTableExpr drop_table = 4;
|
|
TruncateTableExpr truncate_table = 7;
|
|
}
|
|
}
|
|
|
|
message CreateTableExpr {
|
|
string catalog_name = 1;
|
|
string schema_name = 2;
|
|
string table_name = 3;
|
|
string desc = 4;
|
|
repeated ColumnDef column_defs = 5;
|
|
string time_index = 6;
|
|
repeated string primary_keys = 7;
|
|
bool create_if_not_exists = 8;
|
|
map<string, string> table_options = 9;
|
|
TableId table_id = 10;
|
|
repeated uint32 region_numbers = 11;
|
|
string engine = 12;
|
|
}
|
|
|
|
message AlterExpr {
|
|
string catalog_name = 1;
|
|
string schema_name = 2;
|
|
string table_name = 3;
|
|
oneof kind {
|
|
AddColumns add_columns = 4;
|
|
DropColumns drop_columns = 5;
|
|
RenameTable rename_table = 6;
|
|
}
|
|
TableId table_id = 7;
|
|
// table version before altering.
|
|
uint64 table_version = 8;
|
|
}
|
|
|
|
message DropTableExpr {
|
|
string catalog_name = 1;
|
|
string schema_name = 2;
|
|
string table_name = 3;
|
|
TableId table_id = 4;
|
|
}
|
|
|
|
message CreateDatabaseExpr {
|
|
string database_name = 1;
|
|
bool create_if_not_exists = 2;
|
|
map<string, string> options = 3;
|
|
}
|
|
|
|
message TruncateTableExpr {
|
|
string catalog_name = 1;
|
|
string schema_name = 2;
|
|
string table_name = 3;
|
|
TableId table_id = 4;
|
|
}
|
|
|
|
message AddColumns { repeated AddColumn add_columns = 1; }
|
|
|
|
message DropColumns { repeated DropColumn drop_columns = 1; }
|
|
|
|
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;
|
|
}
|
|
|
|
message DropColumn { string name = 1; }
|
|
|
|
message TableId { uint32 id = 1; }
|