-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-14796][SQL] Add spark.sql.optimizer.inSetConversionThreshold config option. #12562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,11 +17,14 @@ | |
|
|
||
| package org.apache.spark.sql.catalyst.optimizer | ||
|
|
||
| import scala.collection.immutable.HashSet | ||
|
|
||
| import org.apache.spark.sql.catalyst.SimpleCatalystConf | ||
| import org.apache.spark.sql.catalyst.analysis.{EliminateSubqueryAliases, UnresolvedAttribute} | ||
| import org.apache.spark.sql.catalyst.dsl.expressions._ | ||
| import org.apache.spark.sql.catalyst.dsl.plans._ | ||
| import org.apache.spark.sql.catalyst.expressions._ | ||
| import org.apache.spark.sql.catalyst.plans.logical.{LocalRelation, LogicalPlan} | ||
| import org.apache.spark.sql.catalyst.plans.logical.{Filter, LocalRelation, LogicalPlan} | ||
| import org.apache.spark.sql.catalyst.plans.PlanTest | ||
| import org.apache.spark.sql.catalyst.rules.RuleExecutor | ||
| import org.apache.spark.sql.types._ | ||
|
|
@@ -36,7 +39,7 @@ class OptimizeInSuite extends PlanTest { | |
| NullPropagation, | ||
| ConstantFolding, | ||
| BooleanSimplification, | ||
| OptimizeIn) :: Nil | ||
| OptimizeIn(SimpleCatalystConf(true))) :: Nil | ||
|
||
| } | ||
|
|
||
| val testRelation = LocalRelation('a.int, 'b.int, 'c.int) | ||
|
|
@@ -128,4 +131,21 @@ class OptimizeInSuite extends PlanTest { | |
| comparePlans(optimized, correctAnswer) | ||
| } | ||
|
|
||
| test("OptimizedIn test: Use configuration.") { | ||
|
||
| val plan = | ||
| testRelation | ||
| .where(In(UnresolvedAttribute("a"), Seq(Literal(1), Literal(2), Literal(3)))) | ||
| .analyze | ||
|
|
||
| val notOptimizedPlan = OptimizeIn(SimpleCatalystConf(true))(plan) | ||
| comparePlans(notOptimizedPlan, plan) | ||
|
|
||
| val optimizedPlan = OptimizeIn(SimpleCatalystConf(true, optimizerMinSetSize = 2))(plan) | ||
| optimizedPlan match { | ||
| case Filter(cond, _) | ||
| if cond.isInstanceOf[InSet] && cond.asInstanceOf[InSet].getHSet().size == 3 => | ||
| // pass | ||
| case _ => fail("Unexpected result for OptimizedIn") | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,10 +54,16 @@ object SQLConf { | |
|
|
||
| val OPTIMIZER_MAX_ITERATIONS = SQLConfigBuilder("spark.sql.optimizer.maxIterations") | ||
| .internal() | ||
| .doc("The max number of iterations the optimizer and analyzer runs") | ||
| .doc("The max number of iterations the optimizer and analyzer runs.") | ||
| .intConf | ||
| .createWithDefault(100) | ||
|
|
||
| val OPTIMIZER_MIN_SET_SIZE = SQLConfigBuilder("spark.sql.optimizer.minSetSize") | ||
| .internal() | ||
| .doc("The minimum threshold of set size to be optimized.") | ||
| .intConf | ||
| .createWithDefault(10) | ||
|
||
|
|
||
| val ALLOW_MULTIPLE_CONTEXTS = SQLConfigBuilder("spark.sql.allowMultipleContexts") | ||
| .doc("When set to true, creating multiple SQLContexts/HiveContexts is allowed. " + | ||
| "When set to false, only one SQLContext/HiveContext is allowed to be created " + | ||
|
|
@@ -529,6 +535,8 @@ private[sql] class SQLConf extends Serializable with CatalystConf with Logging { | |
|
|
||
| def optimizerMaxIterations: Int = getConf(OPTIMIZER_MAX_ITERATIONS) | ||
|
|
||
| def optimizerMinSetSize: Int = getConf(OPTIMIZER_MIN_SET_SIZE) | ||
|
|
||
| def checkpointLocation: String = getConf(CHECKPOINT_LOCATION) | ||
|
|
||
| def filesMaxPartitionBytes: Long = getConf(FILES_MAX_PARTITION_BYTES) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you use this import?