Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4701#discussion_r25122197
  
    --- Diff: core/src/test/scala/org/apache/spark/rdd/JdbcRDDSuite.scala ---
    @@ -29,22 +29,42 @@ class JdbcRDDSuite extends FunSuite with BeforeAndAfter 
with LocalSparkContext {
         Class.forName("org.apache.derby.jdbc.EmbeddedDriver")
         val conn = 
DriverManager.getConnection("jdbc:derby:target/JdbcRDDSuiteDb;create=true")
         try {
    -      val create = conn.createStatement
    -      create.execute("""
    -        CREATE TABLE FOO(
    -          ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, 
INCREMENT BY 1),
    -          DATA INTEGER
    -        )""")
    -      create.close()
    -      val insert = conn.prepareStatement("INSERT INTO FOO(DATA) VALUES(?)")
    -      (1 to 100).foreach { i =>
    -        insert.setInt(1, i * 2)
    -        insert.executeUpdate
    +
    +      try {
    +        val create = conn.createStatement
    +        create.execute("""
    +          CREATE TABLE FOO(
    +            ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 
1, INCREMENT BY 1),
    +            DATA INTEGER
    +          )""")
    +        create.close()
    +        val insert = conn.prepareStatement("INSERT INTO FOO(DATA) 
VALUES(?)")
    +        (1 to 100).foreach { i =>
    +          insert.setInt(1, i * 2)
    +          insert.executeUpdate
    +        }
    +        insert.close()
    +      } catch {
    +        case e: SQLException if e.getSQLState == "X0Y32" =>
    +        // table exists
           }
    -      insert.close()
    -    } catch {
    -      case e: SQLException if e.getSQLState == "X0Y32" =>
    +
    +      try {
    +        val create = conn.createStatement
    +        create.execute("CREATE TABLE BIGINT_TEST(ID BIGINT NOT NULL, DATA 
INTEGER)")
    +        create.close()
    +        val insert = conn.prepareStatement("INSERT INTO BIGINT_TEST 
VALUES(?,?)")
    +        (1 to 100).foreach { i =>
    +          insert.setLong(1, 100000000000000000L +  4000000000000000L * i)
    +          insert.setInt(2, i)
    +          insert.executeUpdate
    +        }
    +        insert.close()
    +      } catch {
    --- End diff --
    
    LGTM except can't we keep this catch block in common in the outer try 
block? I realize it would mean changing some of the variable names in the 
second block.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to