Hi team,

I’m trying to integrate Druid with Calcite by using calcite-druid adapter.
After following the tutorial, we could connect Calcite with Druid and fetching 
metadata back.
But when trying to execute query with below SQL, the DSL generated by Calcite 
is translating the __time where clause by using the combination of full time 
period intervals + filters to specify the specified time range.  But this kind 
of interpreting results in a bad query performance.

Is there any way that we could achieve that translating the __time where clause 
directly into interval field as shown below in the “Desired DSL for interval 
field” section?

Thank you.

SQL:
SELECT * FROM xxx WHERE __time > '2021-06-06T00:00:15+08:00' AND __time < 
'2021-06-07T00:00:15+08:00' LIMIT 10

DSL Generated by Calcite:
{
    "queryType": "scan",
    "dataSource": "xxx",
    "intervals": [
        "1900-01-01T00:00:00.000Z/3000-01-01T00:00:00.000Z"
    ],
    "filter": {
        "type": "and",
        "fields": [
            {
                "type": "expression",
                "expression": "(\"__time\" > 
timestamp_parse('2021-06-06T00:00:15\\u002B08:00','','Asia/Shanghai'))"
            },
            {
                "type": "expression",
                "expression": "(\"__time\" < 
timestamp_parse('2021-06-07T00:00:15\\u002B08:00','','Asia/Shanghai'))"
            }
        ]
    },
    "columns": [
        "__time",
        ...
    ],
    "resultFormat": "compactedList",
    "limit": 10
}

Desired DSL for the interval field:
"intervals": [ "2021-06-07T00:00:15+08:00/2021-06-08T00:00:15+08:00" ]


Regards,
Chi

Reply via email to