Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/13286#discussion_r64490915
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/IncrementalExecution.scala
---
@@ -35,15 +35,36 @@ class IncrementalExecution private[sql](
val currentBatchId: Long)
extends QueryExecution(sparkSession, logicalPlan) {
- // TODO: make this always part of planning.
- val stateStrategy =
sparkSession.sessionState.planner.StatefulAggregationStrategy :: Nil
-
// Modified planner with stateful operations.
override def planner: SparkPlanner =
new SparkPlanner(
sparkSession.sparkContext,
sparkSession.sessionState.conf,
- stateStrategy)
+ Nil) {
+
+ override def strategies: Seq[Strategy] = {
+ StatefulAggregationStrategy +: super.strategies
+ }
+
+ /**
+ * Used to plan aggregation queries that are computed incrementally
as part of a
+ * [[org.apache.spark.sql.ContinuousQuery]].
+ */
+ object StatefulAggregationStrategy extends Strategy {
+ override def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match
{
+ case PhysicalAggregation(
+ namedGroupingExpressions, aggregateExpressions,
rewrittenResultExpressions, child) =>
+ execution.aggregate.Utils.planStreamingAggregation(
+ namedGroupingExpressions,
+ aggregateExpressions,
+ rewrittenResultExpressions,
+ outputMode,
--- End diff --
The strategy has been moved from SparkStrategies to IncrementalExecution to
allow StatefulAggregationStrategy to access the output mode. Is there a better
design that involves minimal changes?
An alternative to passing the output mode explicitly could have been a
logic plan node that stores the output mode in the plan itself, and the
StatefulAggregationStrategy somehow finding it out from the plan itself. But I
think this change is a little complicated.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]