spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] amanomer commented on a change in pull request #26472: [SPARK-29838][SQL] PostgreSQL dialect: cast to timestamp
Date Sat, 16 Nov 2019 17:32:55 GMT
amanomer commented on a change in pull request #26472: [SPARK-29838][SQL] PostgreSQL dialect:
cast to timestamp
URL: https://github.com/apache/spark/pull/26472#discussion_r347100146
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/postgreSQL/PostgreCastBase.scala
 ##########
 @@ -68,16 +91,47 @@ case class PostgreCastToBoolean(child: Expression, timeZoneId: Option[String])
             throw new IllegalArgumentException("invalid input syntax for type boolean: $c");
           }
         """
-
     case IntegerType =>
       super.castToBooleanCode(from)
   }
+}
 
-  override def dataType: DataType = BooleanType
+case class PostgreCastToTimestamp(child: Expression, timeZoneId: Option[String])
+  extends PostgreCastBase(TimestampType) {
 
-  override def nullable: Boolean = child.nullable
+  override def fromTypes: TypeCollection = TypeCollection(StringType, DateType, NullType)
 
-  override def toString: String = s"PostgreCastToBoolean($child as ${dataType.simpleString})"
+  override def withTimeZone(timeZoneId: String): TimeZoneAwareExpression =
+    copy(timeZoneId = Option(timeZoneId))
 
-  override def sql: String = s"CAST(${child.sql} AS ${dataType.sql})"
+  override def castToTimestamp(from: DataType): Any => Any = from match {
+    case StringType =>
+      buildCast[UTF8String](_, utfs => DateTimeUtils.stringToTimestamp(utfs, zoneId)
 
 Review comment:
   Thanks for your suggestion.  I will check this.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


Mime
View raw message