diff --git a/src/main/scala/catalyst/analysis/HiveTypeCoercion.scala b/src/main/scala/catalyst/analysis/HiveTypeCoercion.scala index fced1e2df89fa..ce2f660a7c778 100644 --- a/src/main/scala/catalyst/analysis/HiveTypeCoercion.scala +++ b/src/main/scala/catalyst/analysis/HiveTypeCoercion.scala @@ -190,7 +190,7 @@ trait HiveTypeCoercion { case Sum(e) if e.dataType == StringType => Sum(Cast(e, DoubleType)) case Average(e) if e.dataType == StringType => - Sum(Cast(e, DoubleType)) + Average(Cast(e, DoubleType)) } } @@ -252,7 +252,6 @@ trait HiveTypeCoercion { case s @ Sum(e @ DecimalType()) => s // Decimal is already the biggest. case Sum(e @ IntegralType()) if e.dataType != LongType => Sum(Cast(e, LongType)) case Sum(e @ FractionalType()) if e.dataType != DoubleType => Sum(Cast(e, DoubleType)) - } } } diff --git a/src/main/scala/catalyst/rules/RuleExecutor.scala b/src/main/scala/catalyst/rules/RuleExecutor.scala index 59c5f29c83f49..69cd1dae5b00a 100644 --- a/src/main/scala/catalyst/rules/RuleExecutor.scala +++ b/src/main/scala/catalyst/rules/RuleExecutor.scala @@ -2,8 +2,9 @@ package catalyst package rules import trees._ +import util._ -abstract class RuleExecutor[TreeType <: TreeNode[_]] { +abstract class RuleExecutor[TreeType <: TreeNode[_]] extends Logging { /** * An execution strategy for rules that indicates the maximum number of executions. If the @@ -38,7 +39,19 @@ abstract class RuleExecutor[TreeType <: TreeNode[_]] { // Run until fix point (or the max number of iterations as specified in the strategy. while (iteration < batch.strategy.maxIterations && !curPlan.fastEquals(lastPlan)) { lastPlan = curPlan - curPlan = batch.rules.foldLeft(curPlan) { case (curPlan, rule) => rule(curPlan) } + curPlan = batch.rules.foldLeft(curPlan) { + case (curPlan, rule) => + val result = rule(curPlan) + if(!result.fastEquals(curPlan)) { + logger.debug( + s""" + |=== Applying Rule ${rule.ruleName} === + |${sideBySide(curPlan.treeString, result.treeString).mkString("\n")} + """.stripMargin) + } + + result + } iteration += 1 } }