Skip to content

Commit a113403

Browse files
dengzimingyhuang-db
authored andcommitted
[SPARK-52363][SQL][TESTS] Analyzer NameScope test for nested struct fields inside map values
### What changes were proposed in this pull request? This PR adds test coverage for resolving nested struct fields inside Map values which was missing in the original test suite. ### Why are the changes needed? The new test verifies that multi-part resolution like mapColumn['key'].nestedField works correctly, we already defined a field `col11MapWithStruct`, but we didn't test it properly. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Unneeded ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#51059 from dengziming/SPARK-52363. Authored-by: dengziming <dengziming@bytedance.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
1 parent 83033c5 commit a113403

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

sql/core/src/test/scala/org/apache/spark/sql/analysis/resolver/NameScopeSuite.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,23 @@ class NameScopeSuite extends PlanTest {
358358
)
359359
)
360360

361+
val matchedMapStructs = stack.resolveMultipartName(Seq("col11", "key", "field"))
362+
assert(
363+
matchedMapStructs == NameTarget(
364+
candidates = Seq(
365+
GetStructField(GetMapValue(col11MapWithStruct, Literal("key")), 0, Some("field"))),
366+
aliasName = Some("field"),
367+
output = Seq(
368+
col8Struct,
369+
col9NestedStruct,
370+
col10Map,
371+
col11MapWithStruct,
372+
col12Array,
373+
col13ArrayWithStruct
374+
)
375+
)
376+
)
377+
361378
var matchedArrays = stack.resolveMultipartName(Seq("col12", "element"))
362379
assert(
363380
matchedArrays == NameTarget(

0 commit comments

Comments
 (0)