You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ulrich Kramer (Jira)" <ji...@apache.org> on 2023/06/28 10:53:00 UTC
[jira] [Commented] (CALCITE-1593) JoinAssociateRule throws Exception in thread "main" java.lang.AssertionError: Internal error: Error while applying...
[ https://issues.apache.org/jira/browse/CALCITE-1593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17738048#comment-17738048 ]
Ulrich Kramer commented on CALCITE-1593:
----------------------------------------
We fixed a similar problem by changing {{VolcanoPlanner::getCostOrInfinite}} to
{code:java}
private RelOptCost getCostOrInfinite(RelNode rel, RelMetadataQuery mq) {
try {
RelOptCost cost = getCost(rel, mq);
return cost == null ? infCost : cost;
} catch (CyclicMetadataException exc) {
return infCost;
}
}
{code}
> 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
> Priority: Blocker
> Labels: beginner
>
> 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:
> {code}
> 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);
> {code}
>
> So, when I use the four of them I get:
> {noformat}
> 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)
> {noformat}
> 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:
> {noformat}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)
> {noformat}
> 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
(v8.20.10#820010)
Re: [jira] [Commented] (CALCITE-1593) JoinAssociateRule throws Exception in thread "main" java.lang.AssertionError: Internal error: Error while applying...
Posted by LakeShen <sh...@gmail.com>.
Hi [~gtheod],
I had meeted a similar problem once,you could check your RelMetadataQuery
whether it is one instance per query. RelMetadataQuery should not be a
global static instance
Best,
LakeShen
Ulrich Kramer (Jira) <ji...@apache.org> 于2023年6月28日周三 18:53写道:
>
> [
> https://issues.apache.org/jira/browse/CALCITE-1593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17738048#comment-17738048
> ]
>
> Ulrich Kramer commented on CALCITE-1593:
> ----------------------------------------
>
> We fixed a similar problem by changing
> {{VolcanoPlanner::getCostOrInfinite}} to
>
> {code:java}
> private RelOptCost getCostOrInfinite(RelNode rel, RelMetadataQuery mq) {
> try {
> RelOptCost cost = getCost(rel, mq);
> return cost == null ? infCost : cost;
> } catch (CyclicMetadataException exc) {
> return infCost;
> }
> }
> {code}
>
>
>
> > 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
> > Priority: Blocker
> > Labels: beginner
> >
> > 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:
> > {code}
> > 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);
> > {code}
> >
> > So, when I use the four of them I get:
> > {noformat}
> > 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)
> > {noformat}
> > 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:
> > {noformat}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)
> > {noformat}
> > 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
> (v8.20.10#820010)
>