HyukjinKwon commented on a change in pull request #23597: [SPARK-26653][SQL] 
Use Proleptic Gregorian calendar in parsing JDBC lower/upper bounds
URL: https://github.com/apache/spark/pull/23597#discussion_r249629561
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRelation.scala
 ##########
 @@ -174,10 +174,19 @@ private[sql] object JDBCRelation extends Logging {
     (dialect.quoteIdentifier(column.name), column.dataType)
   }
 
-  private def toInternalBoundValue(value: String, columnType: DataType): Long 
= columnType match {
-    case _: NumericType => value.toLong
-    case DateType => DateTimeUtils.fromJavaDate(Date.valueOf(value)).toLong
-    case TimestampType => 
DateTimeUtils.fromJavaTimestamp(Timestamp.valueOf(value))
+  private def toInternalBoundValue(value: String, columnType: DataType): Long 
= {
+    def parse[T](f: UTF8String => Option[T]): T = {
+      f(UTF8String.fromString(value)).getOrElse {
+        throw new IllegalArgumentException(
+          s"Cannot parse the bound value $value as 
${columnType.catalogString}")
+      }
+    }
+    columnType match {
+      case _: NumericType => value.toLong
+      case DateType => parse(stringToDate).toLong
+      case TimestampType =>
+        parse(stringToTimestamp(_, 
getTimeZone(SQLConf.get.sessionLocalTimeZone)))
 
 Review comment:
   How about we mention something like .. all string -> timestamp will respect 
Session timezone, JDBC lower/upper bounds, blabla, ..., and java 8 time will be 
consistently used across code base .. after the sub-tasks in the umbrella are 
resolved? 

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to