You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "godfrey he (Jira)" <ji...@apache.org> on 2021/01/08 12:12:00 UTC

[jira] [Created] (FLINK-20899) encounter ClassCastException when calculating cost in HepPlanner

godfrey he created FLINK-20899:
----------------------------------

             Summary: encounter ClassCastException when calculating cost in HepPlanner
                 Key: FLINK-20899
                 URL: https://issues.apache.org/jira/browse/FLINK-20899
             Project: Flink
          Issue Type: Bug
            Reporter: godfrey he
            Assignee: godfrey he
             Fix For: 1.13.0


After TREACE level is enabled for Logger, we will encounter ClassCastException when executing the following query:
{code:sql}
SELECT COUNT(*) FROM MyTable
{code}

the exception detail is:

{code:java}
java.lang.ClassCastException: org.apache.calcite.plan.RelOptCostImpl$Factory cannot be cast to org.apache.flink.table.planner.plan.cost.FlinkCostFactory

	at org.apache.flink.table.planner.plan.nodes.physical.common.CommonPhysicalExchange.computeSelfCost(CommonPhysicalExchange.scala:53)
	at org.apache.flink.table.planner.plan.metadata.FlinkRelMdNonCumulativeCost.getNonCumulativeCost(FlinkRelMdNonCumulativeCost.scala:41)
	at GeneratedMetadataHandler_NonCumulativeCost.getNonCumulativeCost_$(Unknown Source)
	at GeneratedMetadataHandler_NonCumulativeCost.getNonCumulativeCost(Unknown Source)
	at org.apache.calcite.rel.metadata.RelMetadataQuery.getNonCumulativeCost(RelMetadataQuery.java:288)
	at org.apache.flink.table.planner.plan.metadata.FlinkRelMdCumulativeCost.getCumulativeCost(FlinkRelMdCumulativeCost.scala:38)
	at GeneratedMetadataHandler_CumulativeCost.getCumulativeCost_$(Unknown Source)
	at GeneratedMetadataHandler_CumulativeCost.getCumulativeCost(Unknown Source)
	at GeneratedMetadataHandler_CumulativeCost.getCumulativeCost_$(Unknown Source)
	at GeneratedMetadataHandler_CumulativeCost.getCumulativeCost(Unknown Source)
	at org.apache.calcite.rel.metadata.RelMetadataQuery.getCumulativeCost(RelMetadataQuery.java:269)
	at org.apache.flink.table.planner.plan.metadata.FlinkRelMdCumulativeCost$$anonfun$getCumulativeCost$1.apply(FlinkRelMdCumulativeCost.scala:41)
	at org.apache.flink.table.planner.plan.metadata.FlinkRelMdCumulativeCost$$anonfun$getCumulativeCost$1.apply(FlinkRelMdCumulativeCost.scala:40)
	at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:157)
	at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:157)
	at scala.collection.Iterator$class.foreach(Iterator.scala:891)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
	at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
	at scala.collection.TraversableOnce$class.foldLeft(TraversableOnce.scala:157)
	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
	at org.apache.flink.table.planner.plan.metadata.FlinkRelMdCumulativeCost.getCumulativeCost(FlinkRelMdCumulativeCost.scala:39)
	at GeneratedMetadataHandler_CumulativeCost.getCumulativeCost_$(Unknown Source)
	at GeneratedMetadataHandler_CumulativeCost.getCumulativeCost(Unknown Source)
	at org.apache.calcite.rel.metadata.RelMetadataQuery.getCumulativeCost(RelMetadataQuery.java:269)
	at org.apache.calcite.plan.AbstractRelOptPlanner.getCost(AbstractRelOptPlanner.java:247)
	at org.apache.calcite.plan.hep.HepPlanner.dumpGraph(HepPlanner.java:1023)
	at org.apache.calcite.plan.hep.HepPlanner.setRoot(HepPlanner.java:159)
	at org.apache.flink.table.planner.plan.optimize.program.FlinkHepProgram.optimize(FlinkHepProgram.scala:60)
{code}

The reason is the HepPlanner will calcite the cost of the optimized plan when TRACE is enabled, while the cost factory in hep planner is {{RelOptCostImpl.Factory}} not the sub-class of FlinkCostFactory.

The solution is we should create HepPlanner with the cost factory in the RelOptCluster.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)