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

    https://github.com/apache/spark/pull/20757#discussion_r172842808
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
 ---
    @@ -1408,11 +1409,37 @@ case class ValidateExternalType(child: Expression, 
expected: DataType)
     
       override def dataType: DataType = 
RowEncoder.externalDataTypeForInput(expected)
     
    -  override def eval(input: InternalRow): Any =
    -    throw new UnsupportedOperationException("Only code-generated 
evaluation is supported")
    -
       private val errMsg = s" is not a valid external type for schema of 
${expected.simpleString}"
     
    +  private lazy val checkType = expected match {
    +    case _: DecimalType =>
    +      (value: Any) => {
    +        Seq(classOf[java.math.BigDecimal], classOf[scala.math.BigDecimal], 
classOf[Decimal])
    +          .exists { x => value.getClass.isAssignableFrom(x) }
    +      }
    +    case _: ArrayType =>
    +      (value: Any) => {
    +        value.getClass.isAssignableFrom(classOf[Seq[_]]) || 
value.getClass.isArray
    +      }
    +    case _ if ScalaReflection.isNativeType(expected) =>
    +      (value: Any) => {
    +        
value.getClass.isAssignableFrom(ScalaReflection.classForNativeTypeOf(expected))
    --- 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