spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgaido91 <...@git.apache.org>
Subject [GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...
Date Mon, 16 Jul 2018 16:19:09 GMT
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r202743580
  
    --- 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 --
    
    nit: why isn't this a literal?


---

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


Mime
View raw message