I think what you’re after is how to convert a predicate, say
select * from emp
where (empno = 100 or empno between 200 and 1000)
and empno not between 150 and 400
into a set of ranges
[100], (400, 1000]
Actually we don’t have that in Calcite, but note that literal values of all
data types are Comparable and that Guava has an excellent RangeSet class.
For the Druid adapter we needed to convert expressions like
EXTRACT(YEAR FROM t) = 2016
AND EXTRACT(MONTH FROM t) BETWEEN 5 and 7
into
t BETWEEN ‘2016-05-01’ AND ‘2016-07-31’
and for that we created DateRangeRules (see
https://issues.apache.org/jira/browse/CALCITE-1334
<https://issues.apache.org/jira/browse/CALCITE-1334>). You’ll notice that
DateRangeRules also makes extensive use of RangeSet internally.
Julian
> On Jan 16, 2017, at 5:21 PM, Ambud Sharma <[email protected]> wrote:
>
> Hi,
>
> I am trying use calcite and develop a custom adapter. I have implemented
> the SPI and able to get basic enumerator to work with a simple select query
> and no where clause.
>
> Trying to understand how to convert operators to range scan and push them
> to the underlying data source.
>
> Should it be a rule or a visitor if yes how do you subset the nodes so that
> only the range scannable entity is delivered to the converter. A link to a
> working example would help.
>
> The data source has range scan capability and I can make a method call to
> it.
>
> Thanks and regards,
> Ambud