In my case I'm querying data from multi data source(like csv+mysql
) via a single sql. How can I distinguish the data source for tables and detect what columns are queried on tables by using Calcite? (Meta data of data source available)
Result that I required is something like:
- TableA(col1, col2, col3) -> Data source CSV
- TableB(col1, colx, coly) -> Data source Mysql
My case is something like what Apache Drill(uses Calcite) does, I tried read Drill source code but I cannot find the way how Drill decides the relations.
String sql = "select c.c1, m.c2 from csv.tbl as c, mysql.schema.tbl as m where c.id = m.id”;
Frameworks.ConfigBuilder configBuilder = Frameworks.newConfigBuilder();
configBuilder.defaultSchema(`my SchemaPlus here`);
FrameworkConfig frameworkConfig = configBuilder.build();
Planner planner = Frameworks.getPlanner(frameworkConfig);
SqlNode sqlNode = planner.parse(sql);
planner.validate(sqlNode);
RelRoot relRoot = planner.rel(sqlNode);
This is what now I have, but it seems nothing I wanted there ~_~|||
thannks a lot.