AngersZhuuuu commented on a change in pull request #28490:
URL: https://github.com/apache/spark/pull/28490#discussion_r434971770
##########
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?
emmm grouping sets still have problem.
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]