sadikovi commented on code in PR #37833:
URL: https://github.com/apache/spark/pull/37833#discussion_r965609994
##########
sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala:
##########
@@ -763,6 +763,25 @@ class DataFrameFunctionsSuite extends QueryTest with
SharedSparkSession {
}
}
+ test("SPARK-40292: arrays_zip should retain field names in nested structs") {
+ val df = spark.sql("""
+ select
+ named_struct(
+ 'arr_1', array(named_struct('a', 1, 'b', 2)),
+ 'arr_2', array(named_struct('p', 1, 'q', 2)),
+ 'field', named_struct(
+ 'arr_3', array(named_struct('x', 1, 'y', 2))
+ )
+ ) as obj
+ """)
+
+ val res = df.selectExpr("arrays_zip(obj.arr_1, obj.arr_2, obj.field.arr_3)
as arr")
+
+ val fieldNames = res.schema.head.dataType.asInstanceOf[ArrayType]
+ .elementType.asInstanceOf[StructType].fieldNames
+ assert(fieldNames.toSeq === Seq("arr_1", "arr_2", "arr_3"))
Review Comment:
Before the fix, this would return `Seq("0", "1", "2")`.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]