Skip to content

Commit

Permalink
feat: upgrade protos and libs (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 authored Jan 5, 2024
1 parent 1b233cf commit a2f5de8
Show file tree
Hide file tree
Showing 12 changed files with 30,830 additions and 19,702 deletions.
58 changes: 20 additions & 38 deletions protos/column.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ option java_package = "io.greptime.v1";
option java_outer_classname = "Columns";
option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1";

import "protos/common.proto";

message Column {
string column_name = 1;

enum SemanticType {
TAG = 0;
FIELD = 1;
TIMESTAMP = 2;
}
SemanticType semantic_type = 2;

message Values {
Expand All @@ -50,10 +46,22 @@ message Column {

repeated int32 date_values = 14;
repeated int64 datetime_values = 15;
repeated int64 ts_second_values = 16;
repeated int64 ts_millisecond_values = 17;
repeated int64 ts_microsecond_values = 18;
repeated int64 ts_nanosecond_values = 19;
repeated int64 timestamp_second_values = 16;
repeated int64 timestamp_millisecond_values = 17;
repeated int64 timestamp_microsecond_values = 18;
repeated int64 timestamp_nanosecond_values = 19;
repeated int64 time_second_values = 20;
repeated int64 time_millisecond_values = 21;
repeated int64 time_microsecond_values = 22;
repeated int64 time_nanosecond_values = 23;
repeated int32 interval_year_month_values = 24;
repeated int64 interval_day_time_values = 25;
repeated IntervalMonthDayNano interval_month_day_nano_values = 26;
repeated int64 duration_second_values = 27;
repeated int64 duration_millisecond_values = 28;
repeated int64 duration_microsecond_values = 29;
repeated int64 duration_nanosecond_values = 30;
repeated Decimal128 decimal128_values = 31;
}
// The array of non-null values in this column.
//
Expand All @@ -73,33 +81,7 @@ message Column {

// Helpful in creating vector from column.
ColumnDataType datatype = 5;
}

message ColumnDef {
string name = 1;
ColumnDataType datatype = 2;
bool is_nullable = 3;
bytes default_constraint = 4;
}

enum ColumnDataType {
BOOLEAN = 0;
INT8 = 1;
INT16 = 2;
INT32 = 3;
INT64 = 4;
UINT8 = 5;
UINT16 = 6;
UINT32 = 7;
UINT64 = 8;
FLOAT32 = 9;
FLOAT64 = 10;
BINARY = 11;
STRING = 12;
DATE = 13;
DATETIME = 14;
TIMESTAMP_SECOND = 15;
TIMESTAMP_MILLISECOND = 16;
TIMESTAMP_MICROSECOND = 17;
TIMESTAMP_NANOSECOND = 18;
// Extension for ColumnDataType.
ColumnDataTypeExtension datatype_extension = 6;
}
77 changes: 75 additions & 2 deletions protos/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ option java_package = "io.greptime.v1";
option java_outer_classname = "Common";
option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1";

message ResponseHeader {}

message RequestHeader {
// The `catalog` that is selected to be used in this request.
string catalog = 1;
Expand All @@ -31,6 +29,17 @@ message RequestHeader {
AuthHeader authorization = 3;
// The `dbname` for the request
string dbname = 4;
// Encoded trace_id & span_id, follow the w3c Trace Context
// https://www.w3.org/TR/trace-context/#header-name
map<string, string> tracing_context = 5;
}

message ResponseHeader { Status status = 1; }

message Status {
// Corresponding to the `StatusCode` definition of GreptimeDB
uint32 status_code = 1;
string err_msg = 2;
}

message AuthHeader {
Expand All @@ -50,3 +59,67 @@ message Token { string token = 1; }
message AffectedRows { uint32 value = 1; }

message FlightMetadata { AffectedRows affected_rows = 1; }

enum SemanticType {
TAG = 0;
FIELD = 1;
TIMESTAMP = 2;
}

enum ColumnDataType {
BOOLEAN = 0;
INT8 = 1;
INT16 = 2;
INT32 = 3;
INT64 = 4;
UINT8 = 5;
UINT16 = 6;
UINT32 = 7;
UINT64 = 8;
FLOAT32 = 9;
FLOAT64 = 10;
BINARY = 11;
STRING = 12;
DATE = 13;
DATETIME = 14;
TIMESTAMP_SECOND = 15;
TIMESTAMP_MILLISECOND = 16;
TIMESTAMP_MICROSECOND = 17;
TIMESTAMP_NANOSECOND = 18;
TIME_SECOND = 19;
TIME_MILLISECOND = 20;
TIME_MICROSECOND = 21;
TIME_NANOSECOND = 22;
INTERVAL_YEAR_MONTH = 23;
INTERVAL_DAY_TIME = 24;
INTERVAL_MONTH_DAY_NANO = 25;
DURATION_SECOND = 26;
DURATION_MILLISECOND = 27;
DURATION_MICROSECOND = 28;
DURATION_NANOSECOND = 29;
DECIMAL128 = 30;
}

message IntervalMonthDayNano {
int32 months = 1;
int32 days = 2;
int64 nanoseconds = 3;
}

// (hi: high 64 bits, lo: low 64 bits) are used to keep the decimal128 value.
message Decimal128 {
int64 hi = 1;
int64 lo = 2;
}

// Type extension for some complex types
message ColumnDataTypeExtension {
oneof type_ext {
DecimalTypeExtension decimal_type = 1;
}
}

message DecimalTypeExtension {
int32 precision = 1;
int32 scale = 2;
}
76 changes: 51 additions & 25 deletions protos/ddl.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// 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;
Expand All @@ -6,18 +20,19 @@ option java_package = "io.greptime.v1";
option java_outer_classname = "Ddl";
option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1";

import "protos/column.proto";
import "protos/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`.
// "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;
FlushTableExpr flush_table = 5;
TruncateTableExpr truncate_table = 7;
}
}

Expand All @@ -32,7 +47,6 @@ message CreateTableExpr {
bool create_if_not_exists = 8;
map<string, string> table_options = 9;
TableId table_id = 10;
repeated uint32 region_ids = 11;
string engine = 12;
}

Expand All @@ -51,42 +65,54 @@ message DropTableExpr {
string catalog_name = 1;
string schema_name = 2;
string table_name = 3;
}

message FlushTableExpr {
string catalog_name = 1;
string schema_name = 2;
string table_name = 3;
optional uint32 region_id = 4;
TableId table_id = 4;
bool drop_if_exists = 5;
}

message CreateDatabaseExpr {
//TODO(hl): maybe rename to schema_name?
string database_name = 1;
bool create_if_not_exists = 2;
map<string, string> options = 3;
}

message AddColumns {
repeated AddColumn add_columns = 1;
message TruncateTableExpr {
string catalog_name = 1;
string schema_name = 2;
string table_name = 3;
TableId table_id = 4;
}

message DropColumns {
repeated DropColumn drop_columns = 1;
}
message AddColumns { repeated AddColumn add_columns = 1; }

message RenameTable {
string new_table_name = 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;
AddColumnLocation location = 3;
}

message DropColumn {
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;
string comment = 6;
// Extension for ColumnDataType.
ColumnDataTypeExtension datatype_extension = 7;
}

message TableId {
uint32 id = 1;
message AddColumnLocation {
enum LocationType {
FIRST = 0;
AFTER = 1;
}
LocationType location_type = 1;
string after_column_name = 2;
}
4 changes: 2 additions & 2 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{deps, [
{grpcbox, "0.16.0"},
{ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.3"}}}
{grpcbox, "0.17.1"},
{ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.7"}}}
]}.

{grpc, [{protos, "protos"}, {gpb_opts, [{module_name_suffix, "_pb"}]}]}.
Expand Down
Loading

0 comments on commit a2f5de8

Please sign in to comment.