cloud-fan commented on code in PR #57733:
URL: https://github.com/apache/spark/pull/57733#discussion_r3708819741
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/types/StructTypeSuite.scala:
##########
@@ -506,6 +506,45 @@ class StructTypeSuite extends SparkFunSuite with SQLHelper
{
assert(struct.toString() === "StructType(StructField(a,IntegerType,true))")
}
+ test("SPARK-58525: case-insensitive merge folds case-only field names,
including nested") {
+ // Top-level: a case-only difference merges into a single field keeping
the left name.
+ assert(
+ new StructType().add("value", StringType)
+ .merge(new StructType().add("Value", StringType), caseSensitive =
false) ===
+ new StructType().add("value", StringType))
+
+ // The case-sensitive default keeps both as distinct fields.
+ assert(
+ new StructType().add("value", StringType)
+ .merge(new StructType().add("Value", StringType)) ===
+ new StructType().add("value", StringType).add("Value", StringType))
+
+ // Nested struct: the flag must propagate through the recursive merge
(SPARK-58525), so a
+ // case-only difference nested under a matched parent also folds rather
than producing both.
+ assert(
+ new StructType().add("s", new StructType().add("value", StringType))
+ .merge(
+ new StructType().add("s", new StructType().add("Value", StringType)),
+ caseSensitive = false) ===
+ new StructType().add("s", new StructType().add("value", StringType)))
+
+ // array<struct> element recursion.
+ assert(
+ new StructType().add("a", ArrayType(new StructType().add("value",
StringType)))
+ .merge(
+ new StructType().add("a", ArrayType(new StructType().add("Value",
StringType))),
+ caseSensitive = false) ===
+ new StructType().add("a", ArrayType(new StructType().add("value",
StringType))))
+
+ // map<_, struct> value recursion.
Review Comment:
Please add a `map<struct, _>` key case too. `mergeInternal` recurses through
keys and values independently, and struct keys are valid, so this value-only
case will not catch a regression in the key branch.
--
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]