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

    https://github.com/apache/spark/pull/14086#discussion_r71973330
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCWriteSuite.scala ---
    @@ -145,14 +153,24 @@ class JDBCWriteSuite extends SharedSQLContext with 
BeforeAndAfter {
         assert(2 === spark.read.jdbc(url, "TEST.APPENDTEST", new 
Properties()).collect()(0).length)
       }
     
    -  test("CREATE then INSERT to truncate") {
    +  test("Truncate") {
    +    JdbcDialects.registerDialect(testH2Dialect)
         val df = spark.createDataFrame(sparkContext.parallelize(arr2x2), 
schema2)
         val df2 = spark.createDataFrame(sparkContext.parallelize(arr1x2), 
schema2)
    +    val df3 = spark.createDataFrame(sparkContext.parallelize(arr2x3), 
schema3)
     
         df.write.jdbc(url1, "TEST.TRUNCATETEST", properties)
    -    df2.write.mode(SaveMode.Overwrite).jdbc(url1, "TEST.TRUNCATETEST", 
properties)
    +    df2.write.mode(SaveMode.Overwrite).option("truncate", true)
    +      .jdbc(url1, "TEST.TRUNCATETEST", properties)
         assert(1 === spark.read.jdbc(url1, "TEST.TRUNCATETEST", 
properties).count())
         assert(2 === spark.read.jdbc(url1, "TEST.TRUNCATETEST", 
properties).collect()(0).length)
    +
    +    val m = intercept[SparkException] {
    --- End diff --
    
    To check my understanding here, this overwrites the table with a different 
schema (new column `seq`). This shows the truncate fails because the schema has 
changed.
    
    I guess it would be nice to test the case where the truncate works at 
least, though, we can't really test whether it truncates vs drops.
    
    Could you for example just repeat the code on line 163-166 here to verify 
that overwriting just results in the same results?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to