Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15926#discussion_r88824474
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala
 ---
    @@ -413,6 +413,40 @@ class MetastoreDataSourcesSuite extends QueryTest with 
SQLTestUtils with TestHiv
         }
       }
     
    +  test("saveAsTable(CTAS) using append and insertInto when the target 
table is Hive serde") {
    +    val tableName = "tab1"
    +    withTable(tableName) {
    +      sql(s"CREATE TABLE $tableName STORED AS SEQUENCEFILE AS SELECT 1 AS 
key, 'abc' AS value")
    +
    +      val df = sql(s"SELECT key, value FROM $tableName")
    +      val e = intercept[AnalysisException] {
    +        df.write.mode(SaveMode.Append).saveAsTable(tableName)
    +      }.getMessage
    +      assert(e.contains("Saving data in the Hive serde table 
`default`.`tab1` is not supported " +
    +        "yet. Please use the insertInto() API as an alternative."))
    +
    +      df.write.insertInto(tableName)
    +      checkAnswer(
    +        sql(s"SELECT * FROM $tableName"),
    +        Row(1, "abc") :: Row(1, "abc") :: Nil
    +      )
    +    }
    +  }
    +
    +  test("saveAsTable(CTAS) using overwrite when the target table is Hive 
serde") {
    +    val tableName = "tab1"
    +    withTable(tableName) {
    +      sql(s"CREATE TABLE $tableName STORED AS SEQUENCEFILE AS SELECT 1 AS 
key, 'abc' AS value")
    +      val df = sql(s"SELECT key, value FROM $tableName")
    +      df.write.mode(SaveMode.Overwrite).saveAsTable(tableName)
    +      val tableMeta = 
spark.sessionState.catalog.getTableMetadata(TableIdentifier(tableName))
    +      // When the mode is OVERWRITE, we drop the Hive serde tables and 
create a data source table
    +      // TODO: Based on the definition of OVERWRITE, no change should be 
made on the table
    +      // definition. When recreate the table, we need to create a Hive 
serde table.
    --- End diff --
    
    Let's create a ticket for this bug, instead of writing a test to check this 
wrong behaviour.


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