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

    https://github.com/apache/spark/pull/22707#discussion_r239997805
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/InsertSuite.scala ---
    @@ -774,4 +774,23 @@ class InsertSuite extends QueryTest with 
TestHiveSingleton with BeforeAndAfter
           }
         }
       }
    +
    +  test("SPARK-25717: Insert overwrite a recreated external and partitioned 
table "
    +    + "should remove the historical partition first") {
    +    withTempDir { tmpDir =>
    +      withTable("test_table") {
    +        (0 until 3).foreach { _ =>
    +          sql("DROP TABLE IF EXISTS test_table")
    +          sql(
    +            s"""
    +               |CREATE EXTERNAL TABLE test_table (key int)
    +               |PARTITIONED BY (p int)
    +               |LOCATION 
'${tmpDir.toURI.toString.stripSuffix("/")}/test_table'
    +           """.stripMargin)
    +          sql("INSERT OVERWRITE TABLE test_table PARTITION(p=1) SELECT 1")
    +        }
    +        checkAnswer(sql("SELECT COUNT(*) FROM test_table"), Row(1))
    +      }
    +    }
    --- End diff --
    
    How about wrigint tests for this?;
    ```
        withTempDir { tmpDir =>
          withTable("test_table") {
            // Prepare table data
            sql(
              s"""
                 |CREATE EXTERNAL TABLE test_table(key int)
                 |PARTITIONED BY (p int)
                 |LOCATION '${tmpDir.toURI}'
             """.stripMargin)
            sql("INSERT INTO test_table PARTITION(p=1) SELECT 1")
            checkAnswer(sql("SELECT COUNT(*) FROM test_table"), Row(1))
    
            // Run the test...
            sql("DROP TABLE test_table")
            sql(
              s"""
                 |CREATE EXTERNAL TABLE test_table(key int)
                 |PARTITIONED BY (p int)
                 |LOCATION '${tmpDir.toURI}'
             """.stripMargin)
            sql("INSERT OVERWRITE TABLE test_table PARTITION(p=1) SELECT 1")
            checkAnswer(sql("SELECT COUNT(*) FROM test_table"), Row(1))
          }
        }
    ```


---

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

Reply via email to