Skip to content

Commit

Permalink
[SPARK-26226][SQL] Track optimization phase for streaming queries
Browse files Browse the repository at this point in the history
## What changes were proposed in this pull request?
In an earlier PR, we missed measuring the optimization phase time for streaming queries. This patch adds it.

## How was this patch tested?
Given this is a debugging feature, and it is very convoluted to add tests to verify the phase is set properly, I am not introducing a streaming specific test.

Closes apache#23193 from rxin/SPARK-26226-1.

Authored-by: Reynold Xin <[email protected]>
Signed-off-by: gatorsmile <[email protected]>
  • Loading branch information
rxin authored and gatorsmile committed Dec 2, 2018
1 parent 60e4239 commit 55c9685
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger

import org.apache.spark.internal.Logging
import org.apache.spark.sql.{AnalysisException, SparkSession, Strategy}
import org.apache.spark.sql.catalyst.QueryPlanningTracker
import org.apache.spark.sql.catalyst.expressions.{CurrentBatchTimestamp, ExpressionWithRandomSeed}
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.plans.physical.{AllTuples, ClusteredDistribution, HashPartitioning, SinglePartition}
Expand Down Expand Up @@ -73,7 +74,8 @@ class IncrementalExecution(
* Walk the optimized logical plan and replace CurrentBatchTimestamp
* with the desired literal
*/
override lazy val optimizedPlan: LogicalPlan = {
override
lazy val optimizedPlan: LogicalPlan = tracker.measurePhase(QueryPlanningTracker.OPTIMIZATION) {
sparkSession.sessionState.optimizer.execute(withCachedData) transformAllExpressions {
case ts @ CurrentBatchTimestamp(timestamp, _, _) =>
logInfo(s"Current batch timestamp = $timestamp")
Expand Down

0 comments on commit 55c9685

Please sign in to comment.