You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by ueshin <gi...@git.apache.org> on 2018/10/15 14:48:18 UTC

[GitHub] spark pull request #22724: [SPARK-25734][SQL] Literal should have a value co...

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

    https://github.com/apache/spark/pull/22724#discussion_r225194050
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/literals.scala ---
    @@ -196,6 +197,31 @@ object Literal {
         case other =>
           throw new RuntimeException(s"no default for type $dataType")
       }
    +
    +  private[expressions] def validateLiteralValue(v: Any, dataType: DataType): Unit = {
    +    def doValidate(v: Any, dataType: DataType): Boolean = dataType match {
    +      case BooleanType => v.isInstanceOf[Boolean]
    +      case ByteType => v.isInstanceOf[Byte]
    +      case ShortType => v.isInstanceOf[Short]
    +      case IntegerType | DateType => v.isInstanceOf[Int]
    +      case LongType | TimestampType => v.isInstanceOf[Long]
    +      case FloatType => v.isInstanceOf[Float]
    +      case DoubleType => v.isInstanceOf[Double]
    +      case _: DecimalType => v.isInstanceOf[Decimal]
    +      case CalendarIntervalType => v.isInstanceOf[CalendarInterval]
    +      case BinaryType => v.isInstanceOf[Array[Byte]]
    +      case StringType => v.isInstanceOf[UTF8String]
    +      case _: StructType => v.isInstanceOf[InternalRow]
    +      case _: ArrayType => v.isInstanceOf[ArrayData]
    +      case _: MapType => v.isInstanceOf[MapData]
    --- End diff --
    
    Should validate recursively for `StructType`, `ArrayType`, and `MapType`?


---

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