Repository: spark
Updated Branches:
  refs/heads/master 21c7539a5 -> b158256c2


[SPARK-18045][SQL][TESTS] Move `HiveDataFrameAnalyticsSuite` to package `sql`

## What changes were proposed in this pull request?

The testsuite `HiveDataFrameAnalyticsSuite` has nothing to do with HIVE, we 
should move it to package `sql`.
The original test cases in that suite are splited into two existing testsuites: 
`DataFrameAggregateSuite` tests for the functions and 
~~`SQLQuerySuite`~~`SQLQueryTestSuite` tests for the SQL statements.

## How was this patch tested?
~~Modified `SQLQuerySuite` in package `sql`.~~
Add query file for `SQLQueryTestSuite`.

Author: jiangxingbo <[email protected]>

Closes #15582 from jiangxb1987/group-analytics-test.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/b158256c
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/b158256c
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/b158256c

Branch: refs/heads/master
Commit: b158256c2e719edde3dbdfe27a9a65cd3b3039f4
Parents: 21c7539
Author: jiangxingbo <[email protected]>
Authored: Sun Oct 23 13:28:35 2016 +0200
Committer: Herman van Hovell <[email protected]>
Committed: Sun Oct 23 13:28:35 2016 +0200

----------------------------------------------------------------------
 .../sql-tests/inputs/group-analytics.sql        | 13 +++
 .../sql-tests/results/group-analytics.sql.out   | 87 ++++++++++++++++++++
 .../sql/hive/HiveDataFrameAnalyticsSuite.scala  | 72 ----------------
 3 files changed, 100 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/b158256c/sql/core/src/test/resources/sql-tests/inputs/group-analytics.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/sql-tests/inputs/group-analytics.sql 
b/sql/core/src/test/resources/sql-tests/inputs/group-analytics.sql
new file mode 100644
index 0000000..2f78349
--- /dev/null
+++ b/sql/core/src/test/resources/sql-tests/inputs/group-analytics.sql
@@ -0,0 +1,13 @@
+CREATE OR REPLACE TEMPORARY VIEW testData AS SELECT * FROM VALUES
+(1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 2)
+AS testData(a, b);
+
+-- CUBE on overlapping columns
+SELECT a + b, b, SUM(a - b) FROM testData GROUP BY a + b, b WITH CUBE;
+
+SELECT a, b, SUM(b) FROM testData GROUP BY a, b WITH CUBE;
+
+-- ROLLUP on overlapping columns
+SELECT a + b, b, SUM(a - b) FROM testData GROUP BY a + b, b WITH ROLLUP;
+
+SELECT a, b, SUM(b) FROM testData GROUP BY a, b WITH ROLLUP;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/spark/blob/b158256c/sql/core/src/test/resources/sql-tests/results/group-analytics.sql.out
----------------------------------------------------------------------
diff --git 
a/sql/core/src/test/resources/sql-tests/results/group-analytics.sql.out 
b/sql/core/src/test/resources/sql-tests/results/group-analytics.sql.out
new file mode 100644
index 0000000..8ea7de8
--- /dev/null
+++ b/sql/core/src/test/resources/sql-tests/results/group-analytics.sql.out
@@ -0,0 +1,87 @@
+-- Automatically generated by SQLQueryTestSuite
+-- Number of queries: 5
+
+
+-- !query 0
+CREATE OR REPLACE TEMPORARY VIEW testData AS SELECT * FROM VALUES
+(1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 2)
+AS testData(a, b)
+-- !query 0 schema
+struct<>
+-- !query 0 output
+
+
+
+-- !query 1
+SELECT a + b, b, SUM(a - b) FROM testData GROUP BY a + b, b WITH CUBE
+-- !query 1 schema
+struct<(a + b):int,b:int,sum((a - b)):bigint>
+-- !query 1 output
+2      1       0
+2      NULL    0
+3      1       1
+3      2       -1
+3      NULL    0
+4      1       2
+4      2       0
+4      NULL    2
+5      2       1
+5      NULL    1
+NULL   1       3
+NULL   2       0
+NULL   NULL    3
+
+
+
+-- !query 2
+SELECT a, b, SUM(b) FROM testData GROUP BY a, b WITH CUBE
+-- !query 2 schema
+struct<a:int,b:int,sum(b):bigint>
+-- !query 2 output
+1      1       1
+1      2       2
+1      NULL    3
+2      1       1
+2      2       2
+2      NULL    3
+3      1       1
+3      2       2
+3      NULL    3
+NULL   1       3
+NULL   2       6
+NULL   NULL    9
+
+
+-- !query 3
+SELECT a + b, b, SUM(a - b) FROM testData GROUP BY a + b, b WITH ROLLUP
+-- !query 3 schema
+struct<(a + b):int,b:int,sum((a - b)):bigint>
+-- !query 3 output
+2      1       0
+2      NULL    0
+3      1       1
+3      2       -1
+3      NULL    0
+4      1       2
+4      2       0
+4      NULL    2
+5      2       1
+5      NULL    1
+NULL   NULL    3
+
+
+-- !query 4
+SELECT a, b, SUM(b) FROM testData GROUP BY a, b WITH ROLLUP
+-- !query 4 schema
+struct<a:int,b:int,sum(b):bigint>
+-- !query 4 output
+1      1       1
+1      2       2
+1      NULL    3
+2      1       1
+2      2       2
+2      NULL    3
+3      1       1
+3      2       2
+3      NULL    3
+NULL   NULL    9

http://git-wip-us.apache.org/repos/asf/spark/blob/b158256c/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveDataFrameAnalyticsSuite.scala
----------------------------------------------------------------------
diff --git 
a/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveDataFrameAnalyticsSuite.scala
 
b/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveDataFrameAnalyticsSuite.scala
deleted file mode 100644
index 6477974..0000000
--- 
a/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveDataFrameAnalyticsSuite.scala
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.spark.sql.hive
-
-import org.scalatest.BeforeAndAfterAll
-
-import org.apache.spark.sql.{DataFrame, QueryTest, Row}
-import org.apache.spark.sql.functions._
-import org.apache.spark.sql.hive.test.TestHiveSingleton
-
-// TODO ideally we should put the test suite into the package `sql`, as
-// `hive` package is optional in compiling, however, `SQLContext.sql` doesn't
-// support the `cube` or `rollup` yet.
-class HiveDataFrameAnalyticsSuite extends QueryTest with TestHiveSingleton 
with BeforeAndAfterAll {
-  import spark.implicits._
-  import spark.sql
-
-  private var testData: DataFrame = _
-
-  override def beforeAll() {
-    super.beforeAll()
-    testData = Seq((1, 2), (2, 2), (3, 4)).toDF("a", "b")
-    testData.createOrReplaceTempView("mytable")
-  }
-
-  override def afterAll(): Unit = {
-    try {
-      spark.catalog.dropTempView("mytable")
-    } finally {
-      super.afterAll()
-    }
-  }
-
-  test("rollup") {
-    checkAnswer(
-      testData.rollup($"a" + $"b", $"b").agg(sum($"a" - $"b")),
-      sql("select a + b, b, sum(a - b) from mytable group by a + b, b with 
rollup").collect()
-    )
-
-    checkAnswer(
-      testData.rollup("a", "b").agg(sum("b")),
-      sql("select a, b, sum(b) from mytable group by a, b with 
rollup").collect()
-    )
-  }
-
-  test("cube") {
-    checkAnswer(
-      testData.cube($"a" + $"b", $"b").agg(sum($"a" - $"b")),
-      sql("select a + b, b, sum(a - b) from mytable group by a + b, b with 
cube").collect()
-    )
-
-    checkAnswer(
-      testData.cube("a", "b").agg(sum("b")),
-      sql("select a, b, sum(b) from mytable group by a, b with cube").collect()
-    )
-  }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to