Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20797#discussion_r179355326
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala 
---
    @@ -794,6 +794,52 @@ object ScalaReflection extends ScalaReflection {
         "interface", "long", "native", "new", "null", "package", "private", 
"protected", "public",
         "return", "short", "static", "strictfp", "super", "switch", 
"synchronized", "this", "throw",
         "throws", "transient", "true", "try", "void", "volatile", "while")
    +
    +  val typeJavaMapping = Map[DataType, Class[_]](
    +    BooleanType -> classOf[Boolean],
    +    ByteType -> classOf[Byte],
    +    ShortType -> classOf[Short],
    +    IntegerType -> classOf[Int],
    +    LongType -> classOf[Long],
    +    FloatType -> classOf[Float],
    +    DoubleType -> classOf[Double],
    +    StringType -> classOf[UTF8String],
    +    DateType -> classOf[DateType.InternalType],
    +    TimestampType -> classOf[TimestampType.InternalType],
    +    BinaryType -> classOf[BinaryType.InternalType],
    +    CalendarIntervalType -> classOf[CalendarInterval]
    +  )
    +
    +  val typeBoxedJavaMapping = Map[DataType, Class[_]](
    +    BooleanType -> classOf[java.lang.Boolean],
    +    ByteType -> classOf[java.lang.Byte],
    +    ShortType -> classOf[java.lang.Short],
    +    IntegerType -> classOf[java.lang.Integer],
    +    LongType -> classOf[java.lang.Long],
    +    FloatType -> classOf[java.lang.Float],
    +    DoubleType -> classOf[java.lang.Double],
    +    DateType -> classOf[java.lang.Integer],
    +    TimestampType -> classOf[java.lang.Long]
    +  )
    +
    +  def dataTypeJavaClass(dt: DataType): Class[_] = {
    +    dt match {
    +      case _: DecimalType => classOf[Decimal]
    +      case _: StructType => classOf[InternalRow]
    +      case _: ArrayType => classOf[ArrayData]
    +      case _: MapType => classOf[MapData]
    +      case ObjectType(cls) => cls
    +      case _ => typeJavaMapping.getOrElse(dt, classOf[java.lang.Object])
    +    }
    +  }
    --- End diff --
    
    ok


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to