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_r249798044
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
 ##########
 @@ -1523,4 +1523,37 @@ class JDBCSuite extends QueryTest
     assert(e.contains("The driver could not open a JDBC connection. " +
       "Check the URL: jdbc:mysql://localhost/db"))
   }
+
+  test("parsing timestamp bounds") {
+    DateTimeTestUtils.outstandingTimezonesIds.foreach { timeZone =>
+      withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> timeZone) {
+        Seq(
+          ("1972-07-04 03:30:00", "1972-07-15 20:50:32.5", "1972-07-27 
14:11:05"),
+          ("2019-01-20 12:00:00.502", "2019-01-20 12:00:00.751", "2019-01-20 
12:00:01.000"),
+          (
+            "2019-01-20T00:00:00.123456",
+            "2019-01-20 00:05:00.123456",
+            "2019-01-20T00:10:00.123456"),
+          ("1500-01-20T00:00:00.123456", "1500-01-20 00:05:00.123456", 
"1500-01-20T00:10:00.123456")
+        ).foreach { case (lower, middle, upper) =>
+          val df = spark.read.format("jdbc")
+            .option("url", urlWithUserAndPass)
+            .option("dbtable", "TEST.DATETIME")
+            .option("partitionColumn", "t")
+            .option("lowerBound", lower)
+            .option("upperBound", upper)
+            .option("numPartitions", 2)
+            .load()
+
+          df.logicalPlan match {
+            case LogicalRelation(JDBCRelation(_, parts, _), _, _, _) =>
 
 Review comment:
   Let's avoid to extend arguments fully (see 
https://github.com/databricks/scala-style-guide#pattern-matching).
   
   ```scala
   case plan: LogicalRelation =>
     assert(plan.relation.isInstanceOf[JDBCRelation])
     val parts = plan.relation.asInstanceOf[JDBCRelation].parts
     val whereClauses = 
parts.map(_.asInstanceOf[JDBCPartition].whereClause).toSet
     assert(whereClauses === Set(
       s""""T" < '$middle' or "T" is null""", s""""T" >= '$middle'"""))
   ```

----------------------------------------------------------------
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