I am trying to design the relational table structure and standard SQL query for Apache - IoTDB (a time series database) with Calcite. Now I want to know how i can convert Calcite's logical plan to IoTDB own physical plan easily.
For example, I execute a simple query:
SELECT deviceid, temperature FROM root_ln WHERE deviceid = 'd1'
After parsing by Calcite, Logical Plan represented by RelNode
s is like this:
LogicalProject(DEVICEID=[$1], TEMPERATURE=[$2])
LogicalFilter(condition=[=($1, 'd1')])
EnumerableTableScan(table=[[IoTDBSchema, ROOT_LN]])
And I want to convert it to IoTDB's own physical plan, which i need to provide:(just the simple example)
- Project's path, like
root.ln.d1.temperature
, we execute query by these paths. I have to puttablename(root.ln)
,deviceid(d1)
, andmeasurement(temperature)
together to get a whole path. This needs to scan the whole logical plan. - Project's datatype, like float. I can get it from paths, it's simple.
- Filter's expression, I have to convert
LogicalFilter
's expression to IoTDB's expression again, including parse what$1
means in this example.
I think it involves too much work. When the query becomes more complex, the conversion becomes more difficult too.
So I think maybe there is a simpler way to do this work.