c21 commented on a change in pull request #32944:
URL: https://github.com/apache/spark/pull/32944#discussion_r662649382
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/costing.scala
##########
@@ -17,16 +17,32 @@
package org.apache.spark.sql.execution.adaptive
+import org.apache.spark.internal.Logging
import org.apache.spark.sql.execution.SparkPlan
+import org.apache.spark.util.Utils
/**
- * Represents the cost of a plan.
+ * An interface to represent the cost of a plan.
*/
trait Cost extends Ordered[Cost]
/**
- * Evaluates the cost of a physical plan.
+ * An interface to evaluate the cost of a physical plan.
*/
trait CostEvaluator {
def evaluateCost(plan: SparkPlan): Cost
}
+
+object CostEvaluator extends Logging {
+
+ /**
+ * Instantiates a [[CostEvaluator]] using the given className.
+ */
+ def instantiate(className: String): CostEvaluator = {
+ logDebug(s"Creating CostEvaluator $className")
+ val clazz = Utils.classForName[CostEvaluator](className)
Review comment:
@cloud-fan - good call, updated.
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/simpleCosting.scala
##########
@@ -38,7 +38,7 @@ case class SimpleCost(value: Long) extends Cost {
* A simple implementation of [[CostEvaluator]], which counts the number of
* [[ShuffleExchangeLike]] nodes in the plan.
*/
-object SimpleCostEvaluator extends CostEvaluator {
+case class SimpleCostEvaluator() extends CostEvaluator {
Review comment:
@cloud-fan - yeah, updated.
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
##########
@@ -642,6 +642,13 @@ object SQLConf {
.bytesConf(ByteUnit.BYTE)
.createWithDefault(0L)
+ val ADAPTIVE_COST_EVALUATOR_CLASS =
+ buildConf("spark.sql.adaptive.costEvaluatorClass")
+ .version("3.2.0")
+ .internal()
+ .stringConf
+
.createWithDefault("org.apache.spark.sql.execution.adaptive.SimpleCostEvaluator")
Review comment:
@cloud-fan - sure, updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]