cloud-fan commented on a change in pull request #32972:
URL: https://github.com/apache/spark/pull/32972#discussion_r661252473



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/DataFrameSetOperationsSuite.scala
##########
@@ -922,12 +922,67 @@ class DataFrameSetOperationsSuite extends QueryTest with 
SharedSparkSession {
       }
     }
   }
+
+  test("SPARK-35756: unionByName support struct having same col names but 
different sequence") {
+    // struct having same col names but different sequence
+    var df1 = Seq((1, Struct1(1, 2))).toDF("a", "b")
+    var df2 = Seq((1, Struct2(1, 2))).toDF("a", "b")
+    var unionDF = df1.unionByName(df2)
+    var expected = Row(1, Row(1, 2)) :: Row(1, Row(2, 1)) :: Nil
+    val schema = "`a` INT,`b` STRUCT<`c1`: INT, `c2`: INT>"
+    assert(unionDF.schema.toDDL === schema)

Review comment:
       It's a bit fragile to compare the DDL string, can we compare 
`StructType` instance directly?




-- 
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]

Reply via email to