The goal of Enumerable convention is to create a query plan that is Java source code. Along with that goes the idea that the plan can be run by something like a ‘public static void main’ method, where the only parameters are things you could pass from the command-line.
We’re not literally that strict, but that should give you an idea of what we’re striving for. By not passing objects around we are simplifying things like running the code in a debugger, running the same plan several times and/or in parallel. The one non-primitive argument is the ‘DataContext root’ parameter. This is a map that contains all of the objects we need. It acts as a directory service, so we can look up any Table objects based on their path (schema1.schema2.myTable). If you need complex non-primitive objects a really good pattern is to pass in a string representation of that object (say JSON) and then build the objects using ‘root’ as a directory service. Julian > On Nov 7, 2022, at 1:32 PM, Courtney Robinson <[email protected]> wrote: > > Hello all! > We're looking at Calcite and I've watched the video of BOSS 21 > with Stamatis and Julian. > > All the examples I've seen, including the lucene example from that video > and others like the ES adapter all end up serialising their values that go > into the generated code. > > ConstantExpression luceneQuery = Expressions.constant(((LuceneRel) > input).implement().query*.toString()*); > > See the toString() here. What I am wondering and haven't been able to > figure out is how do I pass the generated lucene Query object rather than a > String form of it? > > I've tried seeing if there was some common object and found the DataContext > that is available in the generated code but there's no way to add a value > into the DataContext from what I can see. > I tried Expressions.dynamic but it's not implemented, couldn't quite get > Expressions.lambda to work either, throws NPE because `body` is missing? > > I want to stick to one question here since I have a few but this is > related. > Is it possible to avoid the code generation here altogether? In the basic > lucene demo, the AbstractEnumerable is extended > and Linq4j.enumerator(searchIndex()) gets returned from enumerator(). > > I guess what I'm trying to ask is if I can use what seems like the simpler > API (returning an enumerator) whilst providing the rules the other example > uses? > > Repo here for those who don't know what I'm referring to > https://github.com/zabetak/calcite-tutorial/blob/main/solution/src/main/java/com/github/zabetak/calcite/tutorial/LuceneEnumerable.java#L71 > > > I'm literally extending the lucene tutorial example so replies in that > context (getting the generated lucene Query object passed around) are > welcome and it's not far of what we're going to need to do later. > > -- > Regards, > Courtney - CEO, Hypi <https://hypi.io/custom-software-development/> > Tel: 020 8123 2413
