[SPARK-53354][CONNECT] Simplify LiteralValueProtoConverter.toCatalystStruct #52098
+63
−93
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.
What changes were proposed in this pull request?
This PR simplifies the
LiteralValueProtoConverter.toCatalystStruct
method by refactoring the struct conversion logic to be more straightforward and maintainable. The main changes include:toCatalystStruct
to return only the converted struct value instead of a tuple(Any, proto.DataType.Struct)
getProtoStructType
method to handle struct type resolution separatelytoCatalystStructInternal
method that takes the struct type as a parameterLiteralValueWithDataType
case class and simplified thegetConverter
method by removing theinferDataType
parametergetInferredDataType
method to support recursive type inference for struct fieldsWhy are the changes needed?
The original method is a bit overly complex with multiple code paths and conditional logic that made it difficult to understand and maintain. This refactoring improves code readability while preserving the same functionality.
Does this PR introduce any user-facing change?
No. This is a pure refactoring that maintains the same external behavior and API.
How was this patch tested?
build/sbt "connect/testOnly *LiteralExpressionProtoConverterSuite"
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor 1.4.5