Skip to content

Commit 762aeaf

Browse files
committed
Remove unneeded rule. More descriptive name for test table.
1 parent d414cd7 commit 762aeaf

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregates.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ case class Average(child: Expression) extends PartialAggregate with trees.UnaryN
214214
override def toString = s"AVG($child)"
215215

216216
override def asPartial: SplitEvaluation = {
217-
val partialSum = Alias(Sum(Cast(child, dataType)), "PartialSum")()
218-
val partialCount = Alias(Cast(Count(child), dataType), "PartialCount")()
219-
val castedSum = Sum(partialSum.toAttribute)
220-
val castedCount = Sum(partialCount.toAttribute)
217+
val partialSum = Alias(Sum(child), "PartialSum")()
218+
val partialCount = Alias(Count(child), "PartialCount")()
219+
val castedSum = Cast(Sum(partialSum.toAttribute), dataType)
220+
val castedCount = Cast(Sum(partialCount.toAttribute), dataType)
221221

222222
SplitEvaluation(
223223
Divide(castedSum, castedCount),

sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class SQLQuerySuite extends QueryTest {
125125

126126
test("average overflow test") {
127127
checkAnswer(
128-
sql("SELECT AVG(a),b FROM testData1 group by b"),
128+
sql("SELECT AVG(a),b FROM largeAndSmallInts group by b"),
129129
Seq((2147483645.0,1),(2.0,2)))
130130
}
131131

sql/core/src/test/scala/org/apache/spark/sql/TestData.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ object TestData {
3030
(1 to 100).map(i => TestData(i, i.toString)))
3131
testData.registerAsTable("testData")
3232

33-
case class TestData1(a: Int, b: Int)
34-
val testData1: SchemaRDD =
33+
case class LargeAndSmallInts(a: Int, b: Int)
34+
val largeAndSmallInts: SchemaRDD =
3535
TestSQLContext.sparkContext.parallelize(
36-
TestData1(2147483644, 1) ::
37-
TestData1(1, 2) ::
38-
TestData1(2147483645, 1) ::
39-
TestData1(2, 2) ::
40-
TestData1(2147483646, 1) ::
41-
TestData1(3, 2) :: Nil)
42-
testData1.registerAsTable("testData1")
36+
LargeAndSmallInts(2147483644, 1) ::
37+
LargeAndSmallInts(1, 2) ::
38+
LargeAndSmallInts(2147483645, 1) ::
39+
LargeAndSmallInts(2, 2) ::
40+
LargeAndSmallInts(2147483646, 1) ::
41+
LargeAndSmallInts(3, 2) :: Nil)
42+
largeAndSmallInts.registerAsTable("largeAndSmallInts")
4343

4444
case class TestData2(a: Int, b: Int)
4545
val testData2: SchemaRDD =

0 commit comments

Comments
 (0)