Skip to content

Commit

Permalink
Remove unneeded rule. More descriptive name for test table.
Browse files Browse the repository at this point in the history
  • Loading branch information
marmbrus committed Jun 10, 2014
1 parent d414cd7 commit 762aeaf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ case class Average(child: Expression) extends PartialAggregate with trees.UnaryN
override def toString = s"AVG($child)"

override def asPartial: SplitEvaluation = {
val partialSum = Alias(Sum(Cast(child, dataType)), "PartialSum")()
val partialCount = Alias(Cast(Count(child), dataType), "PartialCount")()
val castedSum = Sum(partialSum.toAttribute)
val castedCount = Sum(partialCount.toAttribute)
val partialSum = Alias(Sum(child), "PartialSum")()
val partialCount = Alias(Count(child), "PartialCount")()
val castedSum = Cast(Sum(partialSum.toAttribute), dataType)
val castedCount = Cast(Sum(partialCount.toAttribute), dataType)

SplitEvaluation(
Divide(castedSum, castedCount),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class SQLQuerySuite extends QueryTest {

test("average overflow test") {
checkAnswer(
sql("SELECT AVG(a),b FROM testData1 group by b"),
sql("SELECT AVG(a),b FROM largeAndSmallInts group by b"),
Seq((2147483645.0,1),(2.0,2)))
}

Expand Down
18 changes: 9 additions & 9 deletions sql/core/src/test/scala/org/apache/spark/sql/TestData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ object TestData {
(1 to 100).map(i => TestData(i, i.toString)))
testData.registerAsTable("testData")

case class TestData1(a: Int, b: Int)
val testData1: SchemaRDD =
case class LargeAndSmallInts(a: Int, b: Int)
val largeAndSmallInts: SchemaRDD =
TestSQLContext.sparkContext.parallelize(
TestData1(2147483644, 1) ::
TestData1(1, 2) ::
TestData1(2147483645, 1) ::
TestData1(2, 2) ::
TestData1(2147483646, 1) ::
TestData1(3, 2) :: Nil)
testData1.registerAsTable("testData1")
LargeAndSmallInts(2147483644, 1) ::
LargeAndSmallInts(1, 2) ::
LargeAndSmallInts(2147483645, 1) ::
LargeAndSmallInts(2, 2) ::
LargeAndSmallInts(2147483646, 1) ::
LargeAndSmallInts(3, 2) :: Nil)
largeAndSmallInts.registerAsTable("largeAndSmallInts")

case class TestData2(a: Int, b: Int)
val testData2: SchemaRDD =
Expand Down

0 comments on commit 762aeaf

Please sign in to comment.