Skip to content

Commit 5e4d9b4

Browse files
committed
Merge pull request apache#35 from marmbrus/smallFixes
A few small bug fixes and improvements.
2 parents 5479066 + ccdb07a commit 5e4d9b4

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/main/scala/catalyst/analysis/HiveTypeCoercion.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ trait HiveTypeCoercion {
190190
case Sum(e) if e.dataType == StringType =>
191191
Sum(Cast(e, DoubleType))
192192
case Average(e) if e.dataType == StringType =>
193-
Sum(Cast(e, DoubleType))
193+
Average(Cast(e, DoubleType))
194194
}
195195
}
196196

@@ -252,7 +252,6 @@ trait HiveTypeCoercion {
252252
case s @ Sum(e @ DecimalType()) => s // Decimal is already the biggest.
253253
case Sum(e @ IntegralType()) if e.dataType != LongType => Sum(Cast(e, LongType))
254254
case Sum(e @ FractionalType()) if e.dataType != DoubleType => Sum(Cast(e, DoubleType))
255-
256255
}
257256
}
258257
}

src/main/scala/catalyst/rules/RuleExecutor.scala

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package catalyst
22
package rules
33

44
import trees._
5+
import util._
56

6-
abstract class RuleExecutor[TreeType <: TreeNode[_]] {
7+
abstract class RuleExecutor[TreeType <: TreeNode[_]] extends Logging {
78

89
/**
910
* An execution strategy for rules that indicates the maximum number of executions. If the
@@ -38,7 +39,19 @@ abstract class RuleExecutor[TreeType <: TreeNode[_]] {
3839
// Run until fix point (or the max number of iterations as specified in the strategy.
3940
while (iteration < batch.strategy.maxIterations && !curPlan.fastEquals(lastPlan)) {
4041
lastPlan = curPlan
41-
curPlan = batch.rules.foldLeft(curPlan) { case (curPlan, rule) => rule(curPlan) }
42+
curPlan = batch.rules.foldLeft(curPlan) {
43+
case (curPlan, rule) =>
44+
val result = rule(curPlan)
45+
if(!result.fastEquals(curPlan)) {
46+
logger.debug(
47+
s"""
48+
|=== Applying Rule ${rule.ruleName} ===
49+
|${sideBySide(curPlan.treeString, result.treeString).mkString("\n")}
50+
""".stripMargin)
51+
}
52+
53+
result
54+
}
4255
iteration += 1
4356
}
4457
}

0 commit comments

Comments
 (0)