AngersZhuuuu commented on a change in pull request #28490:
URL: https://github.com/apache/spark/pull/28490#discussion_r436324734
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -3496,6 +3496,88 @@ class SQLQuerySuite extends QueryTest with
SharedSparkSession with AdaptiveSpark
checkIfSeedExistsInExplain(df2)
}
+ test("SPARK-31670: Struct Field in groupByExpr with CUBE") {
+ withTable("t") {
+ sql(
+ """CREATE TABLE t(
+ |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 t
+ |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 t
+ |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 t
+ |LATERAL VIEW EXPLODE(c) x AS each
Review comment:
> btw, we must need `lateral view` to reproduce this issue? I mean, this
issue cannot happen without `lateral view`?
No, I changed.
----------------------------------------------------------------
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]