Hi Pranav, The rule that you are probably looking for is EnumerableInterpreterRule [1].
The ScannableTableTest [2] contains a bunch of test cases very similar to what you want to achieve. If you want to see how everything works together, pick one test and run it in debug mode. Best, Stamatis [1] https://github.com/apache/calcite/blob/a505b25eacc473c6ec0ef8abd40c1ccae86297b6/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpreterRule.java [2] https://github.com/apache/calcite/blob/a505b25eacc473c6ec0ef8abd40c1ccae86297b6/core/src/test/java/org/apache/calcite/test/ScannableTableTest.java On Tue, Sep 27, 2022 at 12:20 PM Thomas Rebele <[email protected]> wrote: > Hello Pranav, > > here some untested pseudo-code that could give you an idea how to achieve > this. It probably needs several adaptations to make it work (marked with > "<- here", possibly others). > > private static final Method BIND = Types.lookupMethod(Bindable.class, > > "bind", Bindable.class, DataContext.class); // <- here > > > > private static class EnumerableBindableRel extends AbstractRelNode > > implements EnumerableRel { > > private final BindableRel bindable; > > > > public EnumerableBindableRel(BindableRel bindable) { > > super(bindable.getCluster(), bindable.getTraitSet()); > > this.bindable = bindable; > > } > > > > @Override > > public Result implement(EnumerableRelImplementor implementor, Prefer > > pref) { > > final PhysType physType = PhysTypeImpl.of( > > implementor.getTypeFactory(), > > this.getRowType(), > > JavaRowFormat.ARRAY); // <- here > > > > final BlockBuilder builder = new BlockBuilder(); > > MethodCallExpression call = Expressions.call( // <- here, correct > > arguments? > > implementor.stash(this.bindable, Bindable.class), > > BIND, > > implementor.getRootExpression()); > > > > ParameterExpression resultVar = > > Expressions.parameter(Enumerable.class, "_result"); > > builder.add(Expressions.declare(Modifier.FINAL, resultVar, > call)); > > builder.add(Expressions.return_(null, resultVar)); > > return implementor.result(physType, builder.toBlock()); > > } > > } > > > > private static EnumerableRel getEnumerableRel(BindableRel bindable) { > > return new EnumerableBindableRel(bindable); > > } > > > > Cordialement / Best Regards, > Dr. Thomas Rebele | R&D Developer | Germany | E [email protected] | W > www.tibco.com > > TIBCO Software GmbH | St.-Martin-Str. 106, 81669 München, Deutschland | > Registergericht: Amtsgericht München, HRB 123355 | Geschäftsführer: William > Hughes; Alexander E. Kolar > > Cordialement / Best Regards, > *Dr. Thomas Rebele* | R&D Developer | Germany | *E* *[email protected] > <[email protected]>* | *W* *www.tibco.com <http://www.tibco.com/>* > > *TIBCO Software GmbH* | St.-Martin-Str. 106, 81669 München, Deutschland | > Registergericht: Amtsgericht München, HRB 123355 | Geschäftsführer: William > Hughes; Alexander E. Kolar > > > > On Fri, Sep 23, 2022 at 10:50 PM Pranav Deshpande < > [email protected]> wrote: > > > Dear Apache Calcite Team, > > Is there a way to convert a BindableRel into an EnumerableRel? > > > > There is a rule to convert an EnumerableRel into a BindableRel, but not > the > > other way around. > > > > I am asking this because I wish to have my TableScans use the > > BindableConvention and the rest of my execution using the Enumerable > > Convention [as it has more operators!]. > > > > Regards, > > Pranav > > >
