maropu commented on a change in pull request #28490:
URL: https://github.com/apache/spark/pull/28490#discussion_r434372717



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -3495,6 +3495,59 @@ class SQLQuerySuite extends QueryTest with 
SharedSparkSession with AdaptiveSpark
     assert(df4.schema.head.name === "randn(1)")
     checkIfSeedExistsInExplain(df2)
   }
+
+  test("SPARK-31670: Struct Field in groupByExpr with CUBE") {
+    withTable("t1") {
+      sql(
+        """create table t1(
+          |a string,
+          |b int,
+          |c array<struct<row_id:int,json_string:string>>,
+          |d array<array<string>>,
+          |e array<map<string, int>>)
+          |using orc""".stripMargin)
+
+      checkAnswer(
+        sql(
+          """
+            |select a, each.json_string, sum(b)
+            |from t1
+            |LATERAL VIEW explode(c) x AS each
+            |group by a, each.json_string
+            |with cube
+            |""".stripMargin), Nil)
+
+      checkAnswer(
+        sql(
+          """
+            |select a, get_json_object(each.json_string, '$.i'), sum(b)
+            |from t1
+            |LATERAL VIEW explode(c) x AS each
+            |group by a, get_json_object(each.json_string, '$.i')
+            |with cube
+            |""".stripMargin), Nil)
+
+      checkAnswer(
+        sql(
+          """
+            |select a, each.json_string as json_string, sum(b)
+            |from t1
+            |LATERAL VIEW explode(c) x AS each
+            |group by a, each.json_string
+            |with cube
+            |""".stripMargin), Nil)
+
+      checkAnswer(
+        sql(
+          """
+            |select a, each.json_string as js, sum(b)
+            |from t1
+            |LATERAL VIEW explode(c) x AS each
+            |group by a, each.json_string
+            |with cube

Review comment:
       Could you check the other analytics grouping, too, e.g., GROUPING SETS 
and ROLLUP?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to