George Theodorakis created CALCITE-1593: -------------------------------------------
Summary: JoinAssociateRule throws Exception in thread "main" java.lang.AssertionError: Internal error: Error while applying... Key: CALCITE-1593 URL: https://issues.apache.org/jira/browse/CALCITE-1593 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.10.0 Reporter: George Theodorakis Assignee: Julian Hyde Priority: Blocker I have created my own operators and Convention to apply my custom cost logic. I have tried many rules with both Volcano and HepPlanner and everything works fine. When I apply LoptOptimizeRule I get the correct output. However, when I try to use: JoinPushThroughJoinRule.LEFT, JoinPushThroughJoinRule.RIGHT, JoinAssociateRule.INSTANCE, JoinCommuteRule.INSTANCE something goes wrong. I try to apply them in VolcanoPlanner in the same step I use my converter rules to change the initial Logical Operators to the custom ones. I declare them as: static final RelOptRule SABER_JOIN_PUSH_THROUGH_JOIN_RULE_RIGHT = new JoinPushThroughJoinRule("JoinPushThroughJoinRule", true, SaberJoinRel.class, SaberRelFactories.SABER_LOGICAL_BUILDER); static final RelOptRule SABER_JOIN_PUSH_THROUGH_JOIN_RULE_LEFT = new JoinPushThroughJoinRule("JoinPushThroughJoinRule", false, SaberJoinRel.class, SaberRelFactories.SABER_LOGICAL_BUILDER); static final RelOptRule SABER_JOIN_COMMUTE_RULE = new JoinCommuteRule(SaberJoinRel.class, SaberRelFactories.SABER_LOGICAL_BUILDER, false); So, when I use the four of them I get: Exception in thread "main" java.lang.AssertionError: Internal error: Error while applying rule SaberProjectRule, args [rel#171:LogicalProject.NONE.[](input=rel#170:Subset#20.LOGICAL.[],rowtime=$8,customerid=$9,phone=$10,rowtime0=$0,orderid=$1,productid=$2,units=$3,customerid0=$4,rowtime00=$5,productid0=$6,description=$7)] at org.apache.calcite.util.Util.newInternal(Util.java:792) at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:236) at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:819) at org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:334) at org.apache.calcite.prepare.PlannerImpl.transform(PlannerImpl.java:308) at calcite.planner.SaberPlanner.getLogicalPlan(SaberPlanner.java:257) at calcite.Tester.main(Tester.java:183) Caused by: java.lang.AssertionError: Internal error: Error occurred while applying rule SaberProjectRule at org.apache.calcite.util.Util.newInternal(Util.java:792) at org.apache.calcite.plan.volcano.VolcanoRuleCall.transformTo(VolcanoRuleCall.java:148) at org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:225) at org.apache.calcite.rel.convert.ConverterRule.onMatch(ConverterRule.java:117) at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:213) ... 5 more Caused by: org.apache.calcite.rel.metadata.CyclicMetadataException at org.apache.calcite.rel.metadata.CyclicMetadataException.<clinit>(CyclicMetadataException.java:28) at GeneratedMetadataHandler_RowCount.getRowCount(Unknown Source) at org.apache.calcite.rel.metadata.RelMetadataQuery.getRowCount(RelMetadataQuery.java:201) at org.apache.calcite.rel.metadata.RelMdRowCount.getRowCount(RelMdRowCount.java:132) at GeneratedMetadataHandler_RowCount.getRowCount_$(Unknown Source) at GeneratedMetadataHandler_RowCount.getRowCount(Unknown Source) at org.apache.calcite.rel.metadata.RelMetadataQuery.getRowCount(RelMetadataQuery.java:201) .... If it helps, when I don't use JoinCommuteRule I don't get an exception, but I get wrong result and when I don't use JoinAssociateRule I get: Exception in thread "main" java.lang.StackOverflowError at com.google.common.collect.ImmutableCollection.<init>(ImmutableCollection.java:157) at com.google.common.collect.ImmutableList.<init>(ImmutableList.java:313) at com.google.common.collect.SingletonImmutableList.<init>(SingletonImmutableList.java:35) at com.google.common.collect.ImmutableList.of(ImmutableList.java:76) at org.apache.calcite.rel.SingleRel.getInputs(SingleRel.java:63) at org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:461) Here is a link to the operators I created: https://github.com/giwrgostheod/Calcite-Saber/tree/master/src/main/java/calcite/planner/common -- This message was sent by Atlassian JIRA (v6.3.4#6332)