jovany-wang / metable

A distributed table-like metadata service for managing your large scale cluster with highly performance.
7 stars 8 forks source link

[RFC] Propose C/C++ SQL Client API. #32

Open jovany-wang opened 2 years ago

jovany-wang commented 2 years ago

I'm proposing that introducing C/C++ SQL Client. I list the proposed APIs below. The rules for the APIs are:

Common API

using metable::MeClient;

MeClient cli;
assert cli.Connect("localhost:10001");

MeSqlExecutor sql = cli.GetSqlExecutor();

Create Table

MeTable stu_table = sql.Table()
    .SetName(/*table_name=*/"student")
    .AddField(STRING, "name")
    .AddField(INT, "age")
    .Create();

Select

MeQueryResult<X, Y> result = sql.Select("*").From(stu_table).Where(predicate?).Execute();
meijies commented 2 years ago

chain invocaton is a good idea ,which make user code with sql conveniently. in my case, the only worry is it's not suitable for command line and web user. maybe we support both sql and invocation chain, but sql is higher priority.

if there is no join clause, we can make api more simple as blew example.


// the handler let user process the data as it arrived. 
sql.Table("student").Where(predicate?).query(handler?);

// Filter is another good choice for predicate filter method.
MeQueryResult<X, Y> result = sq.Table("student").Where(predicate?).query();

sql.Table("student").Where(predicate?).sub(handler?);
jovany-wang commented 2 years ago

@meijies Yes. I do believe the sql statements is more important than this one. Let's track it in #4