test: cover nested complex casts#4608
Open
manuzhang wants to merge 2 commits into
Open
Conversation
Add CometCastSuite coverage for array-of-struct casts, struct fields containing arrays, and deeply nested struct casts to both struct and string targets. Co-authored-by: Codex <codex@openai.com>
comphead
reviewed
Jun 9, 2026
comphead
left a comment
Contributor
There was a problem hiding this comment.
Thanks @manuzhang I would love them to be in SQL tests unless it is not possible
Add a SQL test resource that exercises nested struct, array, and array-of-struct casts. Co-authored-by: Codex <codex@openai.com>
comphead
reviewed
Jun 10, 2026
| ORDER BY id | ||
|
|
||
| -- array of structs to string | ||
| query |
Contributor
There was a problem hiding this comment.
we prob also need some negative scenarios.
Nested cast is super deep topic, WDYT if we can have more test combinations?
structs can be tested to cast to objects with missing, extra, renamed, different order fields.
comphead
reviewed
Jun 10, 2026
comphead
left a comment
Contributor
There was a problem hiding this comment.
Thanks @manuzhang I think we are getting on here!
comphead
reviewed
Jun 10, 2026
| } | ||
| } | ||
|
|
||
| test("cast StructType with ArrayType field to StructType") { |
Contributor
There was a problem hiding this comment.
those tests looks portable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Part of #4248.
Rationale for this change
CometCastSuiteand the SQL test resources did not directly exercise recursive cast behavior for arrays of structs, structs containing arrays, or deeper nested structs. These cases are supported recursively and should have focused regression coverage across both the native Comet path and SQL test coverage.What changes are included in this PR?
This adds complex cast coverage in
CometCastSuiteandspark/src/test/resources/sql-tests/expressions/cast/cast_complex.sqlfor:Array(Struct(...))toArray(Struct(...))with field type changes.Array(Struct(...))toString.Structwith anArrayfield to anotherStructwith the inner array element type cast.Struct(Struct(Struct(...)))casts to bothStructandString.The Scala tests use Parquet-backed inputs through
testSingleLineQueryso the native Comet path is exercised, while the SQL test file adds declarative coverage for the same complex cast scenarios.How are these changes tested?
make core./mvnw test -Pjdk17 -Dtest=none -Dsuites=org.apache.comet.CometCastSuite