dongjoon-hyun commented on a change in pull request #31808:
URL: https://github.com/apache/spark/pull/31808#discussion_r592552160
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala
##########
@@ -1091,6 +1091,25 @@ class DataFrameAggregateSuite extends QueryTest
val df = spark.sql(query)
checkAnswer(df, Row(0, "0", 0, 0) :: Row(-1, "1", 1, 1) :: Row(-2, "2", 2,
2) :: Nil)
}
+
+ test("SPARK-34713: group by CreateStruct with ExtractValue") {
+ val structDF = Seq(Tuple1(1 -> 1)).toDF("col")
+ checkAnswer(structDF.groupBy(struct($"col._1")).count().select("count"),
Row(1))
+
+ val arrayOfStructDF = Seq(Tuple1(Seq(1 -> 1))).toDF("col")
+
checkAnswer(arrayOfStructDF.groupBy(struct($"col._1")).count().select("count"),
Row(1))
+
+ val mapDF = Seq(Tuple1(Map("a" -> "a"))).toDF("col")
+ checkAnswer(mapDF.groupBy(struct($"col.a")).count().select("count"),
Row(1))
+
+ val nonStringMapDF = Seq(Tuple1(Map(1 -> 1))).toDF("col")
+ // Spark implicit casts string literal "a" to int to match the key type.
Review comment:
Ah, I was confused here. Thanks.
----------------------------------------------------------------
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]