4paradigm / OpenMLDB

OpenMLDB is an open-source machine learning database that provides a feature platform computing consistent features for training and inference.
https://openmldb.ai
Apache License 2.0
1.6k stars 322 forks source link

ddl parser api is missing in java sdk #588

Closed shawn-happy closed 3 years ago

shawn-happy commented 3 years ago

create ddl parser api for java sdk.

lumianph commented 3 years ago

thanks for the suggestion, @dl239 will follow up this issue BTW, can you please elaborate on your requirements and potential solutions about this issue? We are looking forward to your contribution.

shawn-happy commented 3 years ago

example: the sql parameter is a query statements such as : SELECT a.itemId as itemId, b.brandName as name, b.brandId as brandId, c.actionValue as label FROM a LAST JOIN c ON c.itemId = a.itemId LAST JOIN adinfo ON a.itemId = b.id;

the tableMap parameter is Is used to indicate the mapping between tables and schemas of each table: { "a": [ { "name": "itemId", "type": "string" }, { "name": "reqId", "type": "string" } ], "b": [ { "name": "id", "type": "string" } ], "c": [ { "name": "itemId", "type": "string" }, { "name": "reqId", "type": "string" } ] }

  1. create rpc method in nameserver. proto and define ddl parser request and response e.g: rpc ExecuteDDLParser(DDLParserRequest) returns (DDLParserResponse); message DDLParserRequest{ optional string sql = 3; optional string table = 3; repeated openmldb.common.ColumnDesc column_desc= 1; }

message DDLParserResponse{ optional int32 code = 2; optional string msg = 3; repeated string ddl = 1; }

  1. create virtual ExecuteDDLParser() in name_server_impl.h and Implement ExecuteDDLParser method in name_server_impl.cc void ExecuteDDLParser(RpcController* controller, const DDLParserRequest* request, DDLParserResponse* response, Closure* done);
  2. create a method in ns_client.cc for sql_router can access rpc method

@dl239 @vagetablechicken please review this solution to give me some advice

vagetablechicken commented 3 years ago

Maybe ExtractIndexRequest is better, or DDLParseRequest, not parser request. We want to support tables, but request only has one table and its columns. You could try inner message, like:

message Request {
    message Table{
        optional table_name;
        repeated cols;
    }
   repeated Table tables;
}
dl239 commented 3 years ago

Why add ExecuteDDLParser rpc interface to server? @shawn-happy

shawn-happy commented 3 years ago

i want to auto create table in server after genDDl statement @dl239