Skip to content

Commit 1e7169e

Browse files
Yicong-HuangHyukjinKwon
authored andcommitted
[SPARK-53660][SQL][TESTS] Add unit test for Metadata equality check
### What changes were proposed in this commit? This commit introduces a new unit test to verify the equality check of `StructField` instances with different metadata configurations. ### Why are the changes needed? To ensure that the equality check correctly identifies `StructField` instances with empty and non-empty metadata as unequal. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Added a new unit test. ### Was this patch authored or co-authored using generative AI tooling? No Closes #52397 from Yicong-Huang/ES-1587692/fix-add-test. Authored-by: Yicong-Huang <17627829+Yicong-Huang@users.noreply.github.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
1 parent a2adc43 commit 1e7169e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/types/MetadataSuite.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ class MetadataSuite extends SparkFunSuite {
7979
intercept[NoSuchElementException](meta.getLong("no_such_key"))
8080
}
8181

82+
test("Metadata equality check") {
83+
84+
// Create a StructField with empty metadata
85+
val field1 = StructField("myField", IntegerType, nullable = true, Metadata.empty)
86+
87+
// Create a StructField with non-empty metadata
88+
val metadata = new MetadataBuilder().putString("description", "An integer field").build()
89+
val field2 = StructField("myField", IntegerType, nullable = true, metadata)
90+
91+
assert(!(field1 == field2), s"field1 = $field1, field2 = $field2")
92+
}
93+
8294
test("Kryo serialization for expressions") {
8395
val conf = new SparkConf()
8496
val serializer = new KryoSerializer(conf).newInstance()

0 commit comments

Comments
 (0)