[SPARK-53490][CONNECT][SQL] Fix Protobuf conversion in observed metrics #52236
+245
−137
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 fixes a critical issue in the protobuf conversion of observed metrics in Spark Connect, specifically when dealing with complex data types like structs, arrays, and maps. The main changes include:
Promise[Map[String, Any]]
toPromise[Row]
to preserve type information during protobuf serialization/deserialization.GenericRowWithSchema
objects instead of tuplesLiteralValueProtoConverter
getDataType
method that properly handles all literal typesWhy are the changes needed?
The previous implementation had several issues:
Does this PR introduce any user-facing change?
Yes, this PR fixes a bug that was preventing users from successfully using observed metrics with complex data types (structs, arrays, maps) in Spark Connect. Users can now:
struct()
expressions in observed metrics and receive properly typedGenericRowWithSchema
objectsarray()
expressions in observed metrics and receive properly typed arraysmap()
expressions in observed metrics and receive properly typed mapsPreviously, the code below would fail.
How was this patch tested?
build/sbt "connect-client-jvm/testOnly *ClientE2ETestSuite -- -z SPARK-53490"
build/sbt "connect/testOnly *LiteralExpressionProtoConverterSuite"
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor 1.5.9