Hi guys, I am trying to make the Prepare.optimize() method run faster: https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/prepare/Prepare.java
According to this article: https://calcite.apache.org/docs/adapter.html : "Calcite has two built-in planner engines: class VolcanoPlanner uses dynamic programming and is good for exhaustive search, whereas class HepPlanner fires a sequence of rules in a more fixed order." So, I've figured that I can use HepPlanner, because speed is important to me, so I can use less exhaustive but faster search. I've added a HepPlanner: final HepProgramBuilder programBuilder = HepProgram.builder(); programBuilder.addMatchOrder(HepMatchOrder.ARBITRARY); programBuilder.addRuleInstance(UnionMergeRule.INSTANCE); HepPlanner hepPlanner = new HepPlanner(programBuilder.build()); hepPlanner.setRoot(root.rel); RelNode hepRoot = hepPlanner.findBestExp(); RelRoot hepRelroot = root.withRel(hepRoot); Then I pass this planner into the run() call (substituted "planner" with "hepPlanner"): final RelNode rootRel4 = program.run( hepPlanner, hepRelroot.rel, desiredTraits, materializationList, latticeList); When running unit tests I get exception: java.lang.StackOverflowError at java.security.AccessController.doPrivileged(Native Method) at java.io.PrintWriter.<init>(PrintWriter.java:116) at java.io.PrintWriter.<init>(PrintWriter.java:100) at org.apache.calcite.rel.AbstractRelNode.computeDigest(AbstractRelNode.java:396) at org.apache.calcite.rel.AbstractRelNode.recomputeDigest(AbstractRelNode.java:356) at org.apache.calcite.plan.hep.HepPlanner.addRelToGraph(HepPlanner.java:817) at org.apache.calcite.plan.hep.HepPlanner.applyTransformationResults(HepPlanner.java:741) at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:559) at org.apache.calcite.plan.hep.HepPlanner.depthFirstApply(HepPlanner.java:370) at org.apache.calcite.plan.hep.HepPlanner.depthFirstApply(HepPlanner.java:382) …<many more lines like this> at org.apache.calcite.plan.hep.HepPlanner.depthFirstApply(HepPlanner.java:382) Let me know what I am doing wrong. I've tried skipping the call to run() method, but just using the HepPlanner alone with the newly added code shown above doesnt generate physical plan. Is there a way to use HepPlanner so that it generates physical plan? Thanks, Val
