You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2019/10/24 19:36:53 UTC

[spark] branch branch-2.4 updated: [SPARK-21287][SQL] Remove requirement of fetch_size>=0 from JDBCOptions

This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new ac72b0e  [SPARK-21287][SQL] Remove requirement of fetch_size>=0 from JDBCOptions
ac72b0e is described below

commit ac72b0e380bf064939ff4e9af5d150f578e02d89
Author: fuwhu <be...@163.com>
AuthorDate: Thu Oct 24 12:35:32 2019 -0700

    [SPARK-21287][SQL] Remove requirement of fetch_size>=0 from JDBCOptions
    
    ### What changes were proposed in this pull request?
     Remove the requirement of fetch_size>=0 from JDBCOptions to allow negative fetch size.
    
    ### Why are the changes needed?
    
    Namely, to allow data fetch in stream manner (row-by-row fetch) against MySQL database.
    
    ### Does this PR introduce any user-facing change?
    No
    
    ### How was this patch tested?
    Unit test (JDBCSuite)
    
    This closes #26230 .
    
    Closes #26244 from fuwhu/SPARK-21287-FIX.
    
    Authored-by: fuwhu <be...@163.com>
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
    (cherry picked from commit 92b25295ca0dc5b80aaddb1c8f8d5ef0a250d11e)
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
---
 .../spark/sql/execution/datasources/jdbc/JDBCOptions.scala       | 9 +--------
 .../src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala     | 9 ---------
 2 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala
index d184f3c..5d1feae 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala
@@ -147,14 +147,7 @@ class JDBCOptions(
      """.stripMargin
   )
 
-  val fetchSize = {
-    val size = parameters.getOrElse(JDBC_BATCH_FETCH_SIZE, "0").toInt
-    require(size >= 0,
-      s"Invalid value `${size.toString}` for parameter " +
-        s"`$JDBC_BATCH_FETCH_SIZE`. The minimum value is 0. When the value is 0, " +
-        "the JDBC driver ignores the value and does the estimates.")
-    size
-  }
+  val fetchSize = parameters.getOrElse(JDBC_BATCH_FETCH_SIZE, "0").toInt
 
   // ------------------------------------------------------------
   // Optional parameters only for writing
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
index 585f888..94333e8 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
@@ -436,15 +436,6 @@ class JDBCSuite extends QueryTest
       urlWithUserAndPass, "TEST.PEOPLE", new Properties()).collect().length === 3)
   }
 
-  test("Basic API with illegal fetchsize") {
-    val properties = new Properties()
-    properties.setProperty(JDBCOptions.JDBC_BATCH_FETCH_SIZE, "-1")
-    val e = intercept[IllegalArgumentException] {
-      spark.read.jdbc(urlWithUserAndPass, "TEST.PEOPLE", properties).collect()
-    }.getMessage
-    assert(e.contains("Invalid value `-1` for parameter `fetchsize`"))
-  }
-
   test("Missing partition columns") {
     withView("tempPeople") {
       val e = intercept[IllegalArgumentException] {


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