Skip to content

[SPARK-53520][SQL] Handle TimeType in javaBoxedType()#55948

Open
yadavay-amzn wants to merge 1 commit into
apache:masterfrom
yadavay-amzn:fix/SPARK-53520-timetype-javaboxed
Open

[SPARK-53520][SQL] Handle TimeType in javaBoxedType()#55948
yadavay-amzn wants to merge 1 commit into
apache:masterfrom
yadavay-amzn:fix/SPARK-53520-timetype-javaboxed

Conversation

@yadavay-amzn
Copy link
Copy Markdown
Contributor

@yadavay-amzn yadavay-amzn commented May 18, 2026

What changes were proposed in this pull request?

Adds TimeType handling to javaBoxedType() in EncoderUtils.scala, returning classOf[java.lang.Long] since TimeType is internally stored as microseconds since midnight.

Why are the changes needed?

javaBoxedType() does not handle TimeType, causing a MatchError when encoding Time values. Part of Spark 4.3 release work (SPARK-56754).

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Added EncoderUtilsSuite with a test verifying javaBoxedType(TimeType) returns classOf[java.lang.Long]. Test fails without the fix (MatchError), passes with it.

Was this patch authored or co-authored using generative AI tooling?

No

Adds TimeType handling to javaBoxedType() to return the appropriate
Java boxed type for Time values.

Closes #SPARK-53520
@yadavay-amzn yadavay-amzn force-pushed the fix/SPARK-53520-timetype-javaboxed branch from c432269 to 6804131 Compare May 18, 2026 05:22
@yadavay-amzn
Copy link
Copy Markdown
Contributor Author

yadavay-amzn commented May 20, 2026

@MaxGekk Could you please take a look at this one-liner when you get a chance?
This adds TimeType handling to javaBoxedType() (part of SPARK-56754 / Time SPIP work).

Copy link
Copy Markdown
Member

@MaxGekk MaxGekk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimeType is internally stored as microseconds since midnight.

It is stored as nanoseconds, see #51156

javaBoxedType() does not handle TimeType, causing a MatchError when encoding Time values.

How do you get it if there is the default case?

...
case _ => typeBoxedJavaMapping.getOrElse(dt, classOf[java.lang.Object])

Is this user-visible bug? Can you reproduce it via public API? For example, via an end-to-end round-trip of Row(LocalTime) through the real encoder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants