MaxGekk commented on code in PR #56266:
URL: https://github.com/apache/spark/pull/56266#discussion_r3348925188


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/encoders/EncoderUtils.scala:
##########
@@ -119,16 +117,16 @@ object EncoderUtils {
     }
   }
 
-  @scala.annotation.tailrec
-  def javaBoxedType(dt: DataType): Class[_] = dt match {
+  def javaBoxedType(dt: DataType): Class[_] =
+    TypeOps(dt).map(_.getBoxedJavaClass).getOrElse(javaBoxedTypeDefault(dt))

Review Comment:
   Your analysis is correct, and it's intentional/defensive rather than closing 
a live gap. Both callers of `javaBoxedType` (`ValidateExternalType.checkType`, 
`MapObjects.elementClassTag`) receive the external `ObjectType(...)` for 
non-native encoders, and `MapObjects`'s boxed-element branch only fires for 
native catalyst element types - so `TypeOps(dt).map(_.getBoxedJavaClass)` 
returns `Some` only for dataTypes that don't currently reach `javaBoxedType` in 
their raw form. It directly replaces the explicit `case _: 
TimestampNTZNanosType => classOf[TimestampNanosVal]` arms that the old 
`javaBoxedType` had, which were equally unreached. I kept it because it 
centralizes the dispatch consistently with the rest of the framework and is the 
correct shape if a primitive-backed framework type ever does reach 
`javaBoxedType` (`getBoxedJavaClass` returns the boxed class, `getJavaClass` 
the primitive).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to