@@ -49,12 +49,6 @@ import org.apache.spark.sql.types.StructType
49
49
abstract class SparkStrategy extends GenericStrategy [SparkPlan ] {
50
50
51
51
override protected def planLater (plan : LogicalPlan ): SparkPlan = PlanLater (plan)
52
-
53
- override def apply (plan : LogicalPlan ): Seq [SparkPlan ] = {
54
- doApply(plan).map(sparkPlan => sparkPlan.withStats(plan.stats))
55
- }
56
-
57
- protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ]
58
52
}
59
53
60
54
case class PlanLater (plan : LogicalPlan ) extends LeafExecNode {
@@ -73,7 +67,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
73
67
* Plans special cases of limit operators.
74
68
*/
75
69
object SpecialLimits extends Strategy {
76
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
70
+ override def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
77
71
case ReturnAnswer (rootPlan) => rootPlan match {
78
72
case Limit (IntegerLiteral (limit), Sort (order, true , child))
79
73
if limit < conf.topKSortFallbackThreshold =>
@@ -215,7 +209,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
215
209
hint.rightHint.exists(_.strategy.contains(SHUFFLE_REPLICATE_NL ))
216
210
}
217
211
218
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
212
+ def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
219
213
220
214
// If it is an equi-join, we first look at the join hints w.r.t. the following order:
221
215
// 1. broadcast hint: pick broadcast hash join if the join type is supported. If both sides
@@ -389,7 +383,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
389
383
* on-demand, only when planning in a [[org.apache.spark.sql.execution.streaming.StreamExecution ]]
390
384
*/
391
385
object StatefulAggregationStrategy extends Strategy {
392
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
386
+ override def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
393
387
case _ if ! plan.isStreaming => Nil
394
388
395
389
case EventTimeWatermark (columnName, delay, child) =>
@@ -429,7 +423,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
429
423
* Used to plan the streaming deduplicate operator.
430
424
*/
431
425
object StreamingDeduplicationStrategy extends Strategy {
432
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
426
+ override def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
433
427
case Deduplicate (keys, child) if child.isStreaming =>
434
428
StreamingDeduplicateExec (keys, planLater(child)) :: Nil
435
429
@@ -446,7 +440,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
446
440
* Limit is unsupported for streams in Update mode.
447
441
*/
448
442
case class StreamingGlobalLimitStrategy (outputMode : OutputMode ) extends Strategy {
449
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
443
+ override def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
450
444
case ReturnAnswer (rootPlan) => rootPlan match {
451
445
case Limit (IntegerLiteral (limit), child)
452
446
if plan.isStreaming && outputMode == InternalOutputModes .Append =>
@@ -461,7 +455,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
461
455
}
462
456
463
457
object StreamingJoinStrategy extends Strategy {
464
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = {
458
+ override def apply (plan : LogicalPlan ): Seq [SparkPlan ] = {
465
459
plan match {
466
460
case ExtractEquiJoinKeys (joinType, leftKeys, rightKeys, condition, left, right, _)
467
461
if left.isStreaming && right.isStreaming =>
@@ -482,7 +476,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
482
476
* Used to plan the aggregate operator for expressions based on the AggregateFunction2 interface.
483
477
*/
484
478
object Aggregation extends Strategy {
485
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
479
+ def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
486
480
case PhysicalAggregation (groupingExpressions, aggExpressions, resultExpressions, child)
487
481
if aggExpressions.forall(expr => expr.isInstanceOf [AggregateExpression ]) =>
488
482
val aggregateExpressions = aggExpressions.map(expr =>
@@ -544,7 +538,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
544
538
}
545
539
546
540
object Window extends Strategy {
547
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
541
+ def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
548
542
case PhysicalWindow (
549
543
WindowFunctionType .SQL , windowExprs, partitionSpec, orderSpec, child) =>
550
544
execution.window.WindowExec (
@@ -562,7 +556,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
562
556
protected lazy val singleRowRdd = sparkContext.parallelize(Seq (InternalRow ()), 1 )
563
557
564
558
object InMemoryScans extends Strategy {
565
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
559
+ def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
566
560
case PhysicalOperation (projectList, filters, mem : InMemoryRelation ) =>
567
561
pruneFilterProject(
568
562
projectList,
@@ -580,7 +574,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
580
574
* be replaced with the real relation using the `Source` in `StreamExecution`.
581
575
*/
582
576
object StreamingRelationStrategy extends Strategy {
583
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
577
+ def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
584
578
case s : StreamingRelation =>
585
579
StreamingRelationExec (s.sourceName, s.output) :: Nil
586
580
case s : StreamingExecutionRelation =>
@@ -596,7 +590,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
596
590
* in streaming plans. Conversion for batch plans is handled by [[BasicOperators ]].
597
591
*/
598
592
object FlatMapGroupsWithStateStrategy extends Strategy {
599
- override def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
593
+ override def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
600
594
case FlatMapGroupsWithState (
601
595
func, keyDeser, valueDeser, groupAttr, dataAttr, outputAttr, stateEnc, outputMode, _,
602
596
timeout, child) =>
@@ -614,7 +608,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
614
608
* Strategy to convert EvalPython logical operator to physical operator.
615
609
*/
616
610
object PythonEvals extends Strategy {
617
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
611
+ override def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
618
612
case ArrowEvalPython (udfs, output, child) =>
619
613
ArrowEvalPythonExec (udfs, output, planLater(child)) :: Nil
620
614
case BatchEvalPython (udfs, output, child) =>
@@ -625,7 +619,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
625
619
}
626
620
627
621
object BasicOperators extends Strategy {
628
- override protected def doApply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
622
+ def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
629
623
case d : DataWritingCommand => DataWritingCommandExec (d, planLater(d.query)) :: Nil
630
624
case r : RunnableCommand => ExecutedCommandExec (r) :: Nil
631
625
0 commit comments