[SPARK-53524][CONNECT][SQL][4.0] Fix temporal value conversion in LiteralValueProtoConverter #52324
+129
−11
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 temporal value conversion issues in the
LiteralValueProtoConverter
for Spark Connect. The main changes include:Fixed temporal value conversion in
getConverter
method: Updated the conversion logic for temporal data types (DATE, TIMESTAMP, TIMESTAMP_NTZ, DAY_TIME_INTERVAL, YEAR_MONTH_INTERVAL, TIME) to use proper utility methods fromSparkDateTimeUtils
andSparkIntervalUtils
instead of directly returning raw protobuf values.Added comprehensive test coverage: Extended the
PlanGenerationTestSuite
with a new test case that includes a tuple containing all temporal types to ensure proper conversion and serialization.Updated test expectations: Modified the expected explain output and query test files to reflect the corrected temporal value handling.
Why are the changes needed?
The struct type in typedlit doesn't work well with temporal values due to bugs in type conversions. For example, the code below fails:
Does this PR introduce any user-facing change?
Yes. This PR fixes temporal value conversion in LiteralValueProtoConverter, allowing the struct type in typedlit to work with temporal values.
How was this patch tested?
build/sbt "connect-client-jvm/testOnly org.apache.spark.sql.PlanGenerationTestSuite"
build/sbt "connect/testOnly org.apache.spark.sql.connect.ProtoToParsedPlanTestSuite"
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor 1.5.11