Skip to content

Commit 04898ac

Browse files
committed
Replace type check by pattern match
1 parent ba13a59 commit 04898ac

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

core/src/main/scala/org/apache/spark/sql/catalyst/CatalystTypeConverters.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,11 @@ object CatalystTypeConverters {
429429
// a measurable performance impact. Note that this optimization will be unnecessary if we
430430
// use code generation to construct Scala Row -> Catalyst Row converters.
431431
def convert(maybeScalaValue: Any): Any = {
432-
if (maybeScalaValue.isInstanceOf[Option[Any]]) {
433-
maybeScalaValue.asInstanceOf[Option[Any]].orNull
434-
} else {
435-
maybeScalaValue
432+
maybeScalaValue match {
433+
case option: Option[Any] =>
434+
option.orNull
435+
case _ =>
436+
maybeScalaValue
436437
}
437438
}
438439

0 commit comments

Comments
 (0)