Skip to content

Commit 5cddda8

Browse files
committed
handle null type earlier
1 parent 5f25ca5 commit 5cddda8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUdfs.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ private[hive] case class HiveSimpleUdf(functionClassName: String, children: Seq[
123123
}
124124
} else {
125125
(a: Any) => {
126-
val constructor = matchingConstructors.find { c =>
127-
c.getParameterTypes.head.getName.equals(a.getClass.getName)
128-
}.getOrElse(matchingConstructors.head)
129-
logDebug(
130-
s"Wrapping $a of type ${if (a == null) "null" else a.getClass.getName} $constructor.")
131-
// We must make sure that primitives get boxed java style.
132126
if (a == null) {
133127
null
134128
} else {
129+
val constructor = matchingConstructors.find { c =>
130+
c.getParameterTypes.head.getName.equals(a.getClass.getName)
131+
}.getOrElse(matchingConstructors.head)
132+
logDebug(
133+
s"Wrapping $a of type ${if (a == null) "null" else a.getClass.getName} $constructor.")
134+
// We must make sure that primitives get boxed java style.
135135
constructor.newInstance(a match {
136136
case i: Int => i: java.lang.Integer
137137
case bd: BigDecimal => new HiveDecimal(bd.underlying())

0 commit comments

Comments
 (0)