Skip to content

PlanChangeLogger

PlanChangeLogger is a logging utility for rule executors to log plan changes (at rule and batch level).

Creating Instance

PlanChangeLogger takes no arguments to be created.

PlanChangeLogger is created when:

TreeType

PlanChangeLogger[TreeType <: TreeNode[_]]

PlanChangeLogger is a Scala type constructor (generic class) with TreeType type alias of a subclass of TreeNode.

Logging Plan Changes by Rule

logRule(
  ruleName: String,
  oldPlan: TreeType,
  newPlan: TreeType): Unit

logRule prints out the following message to the logs when the given newPlan and oldPlan are different and the ruleName is included in the spark.sql.planChangeLog.rules configuration property.

=== Applying Rule [ruleName] ===
[oldPlan] [newPlan]

logRule is used when:

Logging Plan Changes by Batch

logBatch(
  batchName: String,
  oldPlan: TreeType,
  newPlan: TreeType): Unit

logBatch prints out one of the following messages to the logs when the given batchName is included in the spark.sql.planChangeLog.batches configuration property.

When the given oldPlan and newPlan are different, logBatch prints out the following message:

=== Result of Batch [batchName] ===
[oldPlan] [newPlan]

Otherwise, logBatch prints out the following message:

Batch [batchName] has no effect.

logBatch is used when:

Logging Metrics

logMetrics(
  metrics: QueryExecutionMetrics): Unit

logMetrics prints out the following message to the logs:

=== Metrics of Executed Rules ===
Total number of runs: [numRuns]
Total time: [totalTime] seconds
Total number of effective runs: [numEffectiveRuns]
Total time of effective runs: [totalTimeEffective] seconds

logMetrics is used when:

  • RuleExecutor is requested to execute

logBasedOnLevel

logBasedOnLevel(
  f: => String): Unit

logBasedOnLevel uses the spark.sql.planChangeLog.level configuration property for the log level and prints out the given f message to the logs.