Adding a MutableJoin is a bit better, if it isn’t too much trouble for you. We will use it one day. :)
> On Jun 5, 2015, at 2:14 AM, Rajat Venkatesh <[email protected]> wrote: > > Actually, I just need to pass through the SubstitutionVisitor phase and > really use the lattice framework. Will it better if instead of throwing an > exception, I add code to give up if SubstitutionVisitor sees a join ? > > On Fri, Jun 5, 2015 at 1:59 PM, Julian Hyde <[email protected]> wrote: > >> Yes, adding a MutableJoin sounds good. >> >> If I recall correctly, there are two approaches to recognizing >> materialized views (SubstitutionVisitor and lattice). You are in >> SubstitutionVisitor, which I believe will struggle with complexity when >> trying to match an N-way join query to an M-way join view. If you can make >> progress, great, but for star-join kinds of queries I recommend using >> lattices. >> >> Julian >> >>> On Jun 1, 2015, at 12:16 AM, Rajat Venkatesh <[email protected]> >> wrote: >>> >>> I am trying to setup a couple of Lattices in calcite. Both of them have >>> joins and have a few common tables between them. >>> >>> After the first lattice is setup, calcite tries to use it in the second >>> lattice since there are common tables. It fails because it cannot >> convert a >>> LogicalJoin to a MutableRel. >>> >>> Is this a gap in implementation ? Can I add a MutableJoin using the same >>> pattern as the other operators ? >>> >>> Repro and stack trace below. >>> On a side note, JUnit does not print the exception message but prints the >>> stack trace. Does anyone else see that ? I do not have the same problem >>> with other Java projects. >>> >>> >>> Repro: >>> >> https://github.com/vrajat/incubator-calcite/commit/76eb6a642bffc1b5326431b90986df37d7399c6c >>> >>> >>> Stack Trace: >>> >>> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 38.789 >> sec >>> <<< FAILURE! - in org.apache.calcite.test.LatticeTest >>> testTwoLattices(org.apache.calcite.test.LatticeTest) Time elapsed: >> 38.789 >>> sec <<< ERROR! >>> java.lang.RuntimeException: exception while preparing [select >>> s."unit_sales", p."brand_name" >>> from "foodmart"."sales_fact_1997" as s >>> join "foodmart"."product" as p using ("product_id") >>> ] >>> at >>> >> org.apache.calcite.plan.SubstitutionVisitor.toMutable(SubstitutionVisitor.java:231) >>> at >>> >> org.apache.calcite.plan.SubstitutionVisitor.toMutable(SubstitutionVisitor.java:215) >>> at >>> >> org.apache.calcite.plan.SubstitutionVisitor.toMutable(SubstitutionVisitor.java:226) >>> at >>> >> org.apache.calcite.plan.SubstitutionVisitor.<init>(SubstitutionVisitor.java:179) >>> at >>> >> org.apache.calcite.plan.volcano.VolcanoPlanner.substitute(VolcanoPlanner.java:411) >>> at >>> >> org.apache.calcite.plan.volcano.VolcanoPlanner.useMaterialization(VolcanoPlanner.java:369) >>> at >>> >> org.apache.calcite.plan.volcano.VolcanoPlanner.useApplicableMaterializations(VolcanoPlanner.java:455) >>> at >>> >> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:736) >>> at org.apache.calcite.tools.Programs$5.run(Programs.java:272) >>> at >> org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:320) >>> at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:142) >>> at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:280) >>> at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:188) >>> at >>> >> org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:534) >>> at >>> >> org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:435) >>> at >>> >> org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:404) >>> at org.apache.calcite.schema.Schemas.prepare(Schemas.java:326) >>> at >>> >> org.apache.calcite.materialize.MaterializationService.defineMaterialization(MaterializationService.java:118) >>> at >>> >> org.apache.calcite.materialize.MaterializationService.defineTile(MaterializationService.java:290) >>> at >>> >> org.apache.calcite.jdbc.CalciteConnectionImpl.init(CalciteConnectionImpl.java:140) >>> at org.apache.calcite.jdbc.Driver$1.onConnectionInit(Driver.java:102) >>> at >>> >> org.apache.calcite.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:145) >>> at java.sql.DriverManager.getConnection(DriverManager.java:571) >>> at java.sql.DriverManager.getConnection(DriverManager.java:187) >>> at >>> >> org.apache.calcite.test.CalciteAssert$MapConnectionFactory.createConnection(CalciteAssert.java:1099) >>> at >>> >> org.apache.calcite.test.CalciteAssert$AssertQuery.createConnection(CalciteAssert.java:1139) >>> at >>> >> org.apache.calcite.test.CalciteAssert$AssertQuery.substitutionMatches(CalciteAssert.java:1232) >>> at >> org.apache.calcite.test.LatticeTest.testTwoLattices(LatticeTest.java:594) >>> >>> -- >>> Rajat Venkatesh | Engg Lead >>> Qubole Inc | www.qubole.com >> >> > > > -- > Rajat Venkatesh | Engg Lead > Qubole Inc | www.qubole.com
