HyukjinKwon commented on a change in pull request #33722:
URL: https://github.com/apache/spark/pull/33722#discussion_r688182487



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/CatalystTypeConverters.scala
##########
@@ -98,20 +98,13 @@ object CatalystTypeConverters {
      * Converts a Scala type to its Catalyst equivalent while automatically 
handling nulls
      * and Options.
      */
-    final def toCatalyst(@Nullable maybeScalaValue: Any): CatalystType = {
-      if (maybeScalaValue == null) {
-        null.asInstanceOf[CatalystType]
-      } else if (maybeScalaValue.isInstanceOf[Option[ScalaInputType]]) {
-        val opt = maybeScalaValue.asInstanceOf[Option[ScalaInputType]]
-        if (opt.isDefined) {
-          toCatalystImpl(opt.get)
-        } else {
-          null.asInstanceOf[CatalystType]
-        }
-      } else {
-        toCatalystImpl(maybeScalaValue.asInstanceOf[ScalaInputType])
+    final def toCatalyst(@Nullable maybeScalaValue: Any): CatalystType =
+      maybeScalaValue match {
+        case null | None => null.asInstanceOf[CatalystType]
+        case opt: Some[ScalaInputType] => toCatalystImpl(opt.get)
+        case other => toCatalystImpl(other.asInstanceOf[ScalaInputType])
       }
-    }

Review comment:
       nit but I would keep this outer braces




-- 
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