Skip to content

Commit 54bd00e

Browse files
committed
Need to put Option first since Option <: Seq.
1 parent 8f3f281 commit 54bd00e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ object ScalaReflection {
4141

4242
/** Returns a catalyst DataType for the given Scala Type using reflection. */
4343
def schemaFor(tpe: `Type`): DataType = tpe match {
44+
case t if t <:< typeOf[Option[_]] =>
45+
val TypeRef(_, _, Seq(optType)) = t
46+
schemaFor(optType)
4447
case t if t <:< typeOf[Product] =>
4548
val params = t.member("<init>": TermName).asMethod.paramss
4649
StructType(
@@ -59,9 +62,6 @@ object ScalaReflection {
5962
case t if t <:< typeOf[String] => StringType
6063
case t if t <:< typeOf[Timestamp] => TimestampType
6164
case t if t <:< typeOf[BigDecimal] => DecimalType
62-
case t if t <:< typeOf[Option[_]] =>
63-
val TypeRef(_, _, Seq(optType)) = t
64-
schemaFor(optType)
6565
case t if t <:< typeOf[java.lang.Integer] => IntegerType
6666
case t if t <:< typeOf[java.lang.Long] => LongType
6767
case t if t <:< typeOf[java.lang.Double] => DoubleType

0 commit comments

Comments
 (0)