Thanks, that I'm trying to do. Thanks Chin and Vladimir for ProjectableFilterableTable approach - I decided to try it and have a look into generated code for the expression like
select count(id) from SAMPLE where firstName='Vladimir' for the RestTable that implements ProjectableFilterableTable - for the 1st step I don't handle filters at all - just to test and try and got follow exception java.lang.AssertionError: unknown expression CAST($2):VARCHAR(8) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" at org.apache.calcite.interpreter.Interpreter$2.execute(Interpreter.java:170) at org.apache.calcite.interpreter.Interpreter$2$1.get(Interpreter.java:177) at org.apache.calcite.interpreter.Interpreter$2.execute(Interpreter.java:130) at org.apache.calcite.interpreter.FilterNode.run(FilterNode.java:42) at org.apache.calcite.interpreter.Interpreter.start(Interpreter.java:97) at org.apache.calcite.interpreter.Interpreter.enumerator(Interpreter.java:64) at org.apache.calcite.linq4j.EnumerableDefaults$6$1.<init>(EnumerableDefaults.java:1554) at org.apache.calcite.linq4j.EnumerableDefaults$6.enumerator(EnumerableDefaults.java:1553) at org.apache.calcite.linq4j.EnumerableDefaults.aggregate(EnumerableDefaults.java:114) at org.apache.calcite.linq4j.DefaultEnumerable.aggregate(DefaultEnumerable.java:107) at Baz.bind(Baz.java:45) While everythng is fine in tests ( e.g. ScannableTableTest ) On 28 January 2015 at 15:43, Vladimir Sitnikov <[email protected]> wrote: > > I got stuck how to manage to do that. > > Github projects with a not-yet-working sample turn out to be helpful. > > >Ideally it could be like a mix of REST filter + filtering in generated > java > code but > > There are at least two ways to do that: > 1) ProjectableFilterableTable. At execution time you'll be given a set > of filters and you'll be able to pick the "supported by your REST" set > of filters. > > 2) MongoFIlter like approach. You create a rule that matches > "Filter(conditions, RestTableScan)", decomposes filter expressions to > the "supported ones" and rewrites the Filter to > Filter(non_supported_by_rest_conditions, > RestTableScan(supported_by_rest_filters)). > This way at query planning time you'll be able to pass "the set of > filters to RestTableScan, so it can use when calling the REST" > -- Regards, Vladimir Dolzhenko.
