Skip to content

Commit

Permalink
[GLUTEN-7856][CORE] Ensure correct enabling of GlutenCostEvaluator (#…
Browse files Browse the repository at this point in the history
…7857)

Closes #7856
  • Loading branch information
weixiuli authored Nov 14, 2024
1 parent 59d5248 commit 73c0610
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private[gluten] class GlutenDriverPlugin extends DriverPlugin with Logging {

postBuildInfoEvent(sc)

setPredefinedConfigs(sc, conf)
setPredefinedConfigs(conf)

// Initialize Backend.
Backend.get().onDriverStart(sc, pluginContext)
Expand Down Expand Up @@ -123,7 +123,7 @@ private[gluten] class GlutenDriverPlugin extends DriverPlugin with Logging {
GlutenEventUtils.post(sc, event)
}

private def setPredefinedConfigs(sc: SparkContext, conf: SparkConf): Unit = {
private def setPredefinedConfigs(conf: SparkConf): Unit = {
// Spark SQL extensions
val extensions = if (conf.contains(SPARK_SESSION_EXTENSIONS.key)) {
s"${conf.get(SPARK_SESSION_EXTENSIONS.key)}," +
Expand All @@ -134,7 +134,10 @@ private[gluten] class GlutenDriverPlugin extends DriverPlugin with Logging {
conf.set(SPARK_SESSION_EXTENSIONS.key, extensions)

// adaptive custom cost evaluator class
if (GlutenConfig.getConf.enableGluten && GlutenConfig.getConf.enableGlutenCostEvaluator) {
val enableGlutenCostEvaluator = conf.getBoolean(
GlutenConfig.GLUTEN_COST_EVALUATOR_ENABLED,
GLUTEN_COST_EVALUATOR_ENABLED_DEFAULT_VALUE)
if (enableGlutenCostEvaluator) {
val costEvaluator = "org.apache.spark.sql.execution.adaptive.GlutenCostEvaluator"
conf.set(SQLConf.ADAPTIVE_CUSTOM_COST_EVALUATOR_CLASS.key, costEvaluator)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,6 @@ class GlutenConfig(conf: SQLConf) extends Logging {

def enableCastAvgAggregateFunction: Boolean = conf.getConf(COLUMNAR_NATIVE_CAST_AGGREGATE_ENABLED)

def enableGlutenCostEvaluator: Boolean = conf.getConf(COST_EVALUATOR_ENABLED)

def dynamicOffHeapSizingEnabled: Boolean =
conf.getConf(DYNAMIC_OFFHEAP_SIZING_ENABLED)

Expand Down Expand Up @@ -648,6 +646,7 @@ object GlutenConfig {
"spark.gluten.memory.dynamic.offHeap.sizing.memory.fraction"

val GLUTEN_COST_EVALUATOR_ENABLED = "spark.gluten.sql.adaptive.costEvaluator.enabled"
val GLUTEN_COST_EVALUATOR_ENABLED_DEFAULT_VALUE = true

var ins: GlutenConfig = _

Expand Down Expand Up @@ -2116,15 +2115,15 @@ object GlutenConfig {
.createWithDefault(true)

val COST_EVALUATOR_ENABLED =
buildConf(GlutenConfig.GLUTEN_COST_EVALUATOR_ENABLED)
buildStaticConf(GlutenConfig.GLUTEN_COST_EVALUATOR_ENABLED)
.internal()
.doc(
"If true and gluten enabled, use " +
"If true, use " +
"org.apache.spark.sql.execution.adaptive.GlutenCostEvaluator as custom cost " +
"evaluator class, else follow the configuration " +
"spark.sql.adaptive.customCostEvaluatorClass.")
.booleanConf
.createWithDefault(true)
.createWithDefault(GLUTEN_COST_EVALUATOR_ENABLED_DEFAULT_VALUE)

val DYNAMIC_OFFHEAP_SIZING_ENABLED =
buildConf(GlutenConfig.GLUTEN_DYNAMIC_OFFHEAP_SIZING_ENABLED)
Expand Down

0 comments on commit 73c0610

Please sign in to comment.