You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ma...@apache.org on 2014/06/10 23:08:00 UTC
git commit: [SQL] Add average overflow test case from #978
Repository: spark
Updated Branches:
refs/heads/master 55a0e87ee -> 1abbde0e8
[SQL] Add average overflow test case from #978
By @egraldlo.
Author: egraldlo <eg...@gmail.com>
Author: Michael Armbrust <mi...@databricks.com>
Closes #1033 from marmbrus/pr/978 and squashes the following commits:
e228c5e [Michael Armbrust] Remove "test".
762aeaf [Michael Armbrust] Remove unneeded rule. More descriptive name for test table.
d414cd7 [egraldlo] fommatting issues
1153f75 [egraldlo] do best to avoid overflowing in function avg().
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/1abbde0e
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/1abbde0e
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/1abbde0e
Branch: refs/heads/master
Commit: 1abbde0e89131ad95e793ac1834c392db46b448e
Parents: 55a0e87
Author: egraldlo <eg...@gmail.com>
Authored: Tue Jun 10 14:07:55 2014 -0700
Committer: Michael Armbrust <mi...@databricks.com>
Committed: Tue Jun 10 14:07:55 2014 -0700
----------------------------------------------------------------------
.../test/scala/org/apache/spark/sql/SQLQuerySuite.scala | 6 ++++++
.../src/test/scala/org/apache/spark/sql/TestData.scala | 11 +++++++++++
2 files changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/1abbde0e/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
index f2d850a..de02bbc 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
@@ -136,6 +136,12 @@ class SQLQuerySuite extends QueryTest {
2.0)
}
+ test("average overflow") {
+ checkAnswer(
+ sql("SELECT AVG(a),b FROM largeAndSmallInts group by b"),
+ Seq((2147483645.0,1),(2.0,2)))
+ }
+
test("count") {
checkAnswer(
sql("SELECT COUNT(*) FROM testData2"),
http://git-wip-us.apache.org/repos/asf/spark/blob/1abbde0e/sql/core/src/test/scala/org/apache/spark/sql/TestData.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/TestData.scala b/sql/core/src/test/scala/org/apache/spark/sql/TestData.scala
index 05de736..330b20b 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/TestData.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/TestData.scala
@@ -30,6 +30,17 @@ object TestData {
(1 to 100).map(i => TestData(i, i.toString)))
testData.registerAsTable("testData")
+ case class LargeAndSmallInts(a: Int, b: Int)
+ val largeAndSmallInts: SchemaRDD =
+ TestSQLContext.sparkContext.parallelize(
+ 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 =
TestSQLContext.sparkContext.parallelize(