HyukjinKwon 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_r268604696
##########
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:
Oh, wait. This PR changes behaviour, right? `logBasedOnLevel` should use the
same signature of `logXxx`, call by name `message: => String` so that it can be
only called the specific log level is enabled. Otherwise, we will always
evaluate `message` even the specific log level isn't enabled.
----------------------------------------------------------------
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]