maropu commented on a change in pull request #24136: [SPARK-27088][SQL] Add a
configuration to set log level for each batch at RuleExecutor
URL: https://github.com/apache/spark/pull/24136#discussion_r268629651
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/rules/RuleExecutor.scala
##########
@@ -172,21 +164,41 @@ abstract class RuleExecutor[TreeType <: TreeNode[_]]
extends Logging {
private val logRules =
SQLConf.get.optimizerPlanChangeRules.map(Utils.stringToSeq)
- def log(ruleName: String, oldPlan: TreeType, newPlan: TreeType): Unit = {
+ private val logBatches =
SQLConf.get.optimizerPlanChangeBatches.map(Utils.stringToSeq)
+
+ def logRule(ruleName: String, oldPlan: TreeType, newPlan: TreeType): Unit
= {
if (logRules.isEmpty || logRules.get.contains(ruleName)) {
lazy val message =
s"""
|=== Applying Rule ${ruleName} ===
|${sideBySide(oldPlan.treeString,
newPlan.treeString).mkString("\n")}
""".stripMargin
- logLevel match {
- case "TRACE" => logTrace(message)
- case "DEBUG" => logDebug(message)
- case "INFO" => logInfo(message)
- case "WARN" => logWarning(message)
- case "ERROR" => logError(message)
- case _ => logTrace(message)
+ logBasedOnLevel(message)
+ }
+ }
+
+ def logBatch(batchName: String, oldPlan: TreeType, newPlan: TreeType):
Unit = {
+ if (logBatches.isEmpty || logBatches.get.contains(batchName)) {
+ lazy val message = if (!oldPlan.fastEquals(newPlan)) {
Review comment:
Also, could we check `Utils.isTesting` so as to avoid verbose logs when
running tests?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]