def getValueFromRexLit()

in src/spark-project/spark-common/src/main/scala/org/apache/spark/sql/SparderTypeUtil.scala [212:263]


  def getValueFromRexLit(literal: RexLiteral): Any = {
    val v = RexLiteral.value(literal)
    val ret = literal.getValue match {
      case s: NlsString =>
        getValueFromNlsString(s)
      case _: GregorianCalendar =>
        if (literal.getTypeName.getName.equals("DATE")) {
          new Date(DateTimeUtils.stringToTimestamp(UTF8String.fromString(v.toString), ZoneId.systemDefault()).get / 1000)
        } else {
          new Timestamp(DateTimeUtils.stringToTimestamp(UTF8String.fromString(v.toString), ZoneId.systemDefault()).get / 1000)
        }
      case range: TimeUnitRange =>
        // Extract(x from y) in where clause
        range.name
      case b: JBoolean =>
        b
      case b: BigDecimal =>
        literal.getType.getSqlTypeName match {
          case SqlTypeName.BIGINT =>
            b.longValue()
          case SqlTypeName.INTEGER =>
            b.intValue()
          case SqlTypeName.DOUBLE =>
            b.doubleValue()
          case SqlTypeName.FLOAT =>
            b.floatValue()
          case SqlTypeName.SMALLINT =>
            b.shortValue()
          case SqlTypeName.TINYINT =>
            b.byteValue()
          case _ =>
            b
        }
      case b: JFloat =>
        b
      case b: JDouble =>
        b
      case b: Integer =>
        b
      case b: JByte =>
        b
      case b: JShort =>
        b
      case b: JLong =>
        b
      case null =>
        null
      case _ =>
        v.toString
    }
    ret
  }