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

[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

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

    https://github.com/apache/spark/pull/21537#discussion_r209353035
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -1024,26 +1033,29 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToIntervalCode(from: DataType): CastFunction = from match {
         case StringType =>
           (c, evPrim, evNull) =>
    -        s"""$evPrim = CalendarInterval.fromString($c.toString());
    +        code"""$evPrim = CalendarInterval.fromString($c.toString());
                if(${evPrim} == null) {
                  ${evNull} = true;
                }
              """.stripMargin
     
       }
     
    -  private[this] def decimalToTimestampCode(d: String): String =
    -    s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()"
    -  private[this] def longToTimeStampCode(l: String): String = s"$l * 1000000L"
    -  private[this] def timestampToIntegerCode(ts: String): String =
    -    s"java.lang.Math.floor((double) $ts / 1000000L)"
    -  private[this] def timestampToDoubleCode(ts: String): String = s"$ts / 1000000.0"
    +  private[this] def decimalToTimestampCode(d: ExprValue): Block = {
    +    val block = code"new java.math.BigDecimal(1000000L)"
    --- End diff --
    
    maybe a `JavaCode.expression` then for this?


---

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