Skip to content

Commit e3e690e

Browse files
committed
Add hook for extraStrategies
1 parent a70d602 commit e3e690e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,14 @@ class SQLContext(@transient val sparkContext: SparkContext)
295295
def table(tableName: String): SchemaRDD =
296296
new SchemaRDD(this, catalog.lookupRelation(None, tableName))
297297

298+
/**
299+
* :: DeveloperApi ::
300+
* Allows extra strategies to be injected into the query planner at runtime. Note this API
301+
* should be consider experimental and is not intended to be stable across releases.
302+
*/
303+
@DeveloperApi
304+
var extraStrategies: Seq[Strategy] = Nil
305+
298306
protected[sql] class SparkPlanner extends SparkStrategies {
299307
val sparkContext: SparkContext = self.sparkContext
300308

@@ -305,6 +313,7 @@ class SQLContext(@transient val sparkContext: SparkContext)
305313
def numPartitions = self.numShufflePartitions
306314

307315
val strategies: Seq[Strategy] =
316+
extraStrategies ++ (
308317
CommandStrategy(self) ::
309318
DataSourceStrategy ::
310319
TakeOrdered ::
@@ -315,7 +324,7 @@ class SQLContext(@transient val sparkContext: SparkContext)
315324
ParquetOperations ::
316325
BasicOperators ::
317326
CartesianProduct ::
318-
BroadcastNestedLoopJoin :: Nil
327+
BroadcastNestedLoopJoin :: Nil)
319328

320329
/**
321330
* Used to build table scan operators where complex projection and filtering are done using

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {
327327
val hivePlanner = new SparkPlanner with HiveStrategies {
328328
val hiveContext = self
329329

330-
override val strategies: Seq[Strategy] = Seq(
330+
override val strategies: Seq[Strategy] = extraStrategies ++ Seq(
331331
DataSourceStrategy,
332332
CommandStrategy(self),
333333
HiveCommandStrategy(self),

0 commit comments

Comments
 (0)