[SQL] Add average overflow test case from #978
By @egraldlo. Author: egraldlo <egraldlo@gmail.com> Author: Michael Armbrust <michael@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().
This commit is contained in:
parent
55a0e87ee4
commit
1abbde0e89
|
@ -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"),
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue