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

    https://github.com/apache/spark/pull/13170#discussion_r63915441
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveCommandSuite.scala
 ---
    @@ -269,6 +270,81 @@ class HiveCommandSuite extends QueryTest with 
SQLTestUtils with TestHiveSingleto
         }
       }
     
    +  test("Truncate Table") {
    +    withTable("non_part_table", "part_table") {
    +      sql(
    +        """
    +          |CREATE TABLE non_part_table (employeeID INT, employeeName 
STRING)
    +          |ROW FORMAT DELIMITED
    +          |FIELDS TERMINATED BY '|'
    +          |LINES TERMINATED BY '\n'
    +        """.stripMargin)
    +
    +      val testData = 
hiveContext.getHiveFile("data/files/employee.dat").getCanonicalPath
    +
    +      sql(s"""LOAD DATA LOCAL INPATH "$testData" INTO TABLE 
non_part_table""")
    +      checkAnswer(
    +        sql("SELECT * FROM non_part_table WHERE employeeID = 16"),
    +        Row(16, "john") :: Nil)
    +
    +      val testResults = sql("SELECT * FROM non_part_table").collect()
    +
    +      intercept[ParseException] {
    +        sql("TRUNCATE TABLE non_part_table COLUMNS (employeeID)")
    +      }
    +
    +      sql("TRUNCATE TABLE non_part_table")
    +      checkAnswer(sql("SELECT * FROM non_part_table"), Seq.empty[Row])
    +
    +      sql(
    +        """
    +          |CREATE TABLE part_table (employeeID INT, employeeName STRING)
    +          |PARTITIONED BY (c STRING, d STRING)
    +          |ROW FORMAT DELIMITED
    +          |FIELDS TERMINATED BY '|'
    +          |LINES TERMINATED BY '\n'
    +        """.stripMargin)
    +
    +      sql(s"""LOAD DATA LOCAL INPATH "$testData" INTO TABLE part_table 
PARTITION(c="1", d="1")""")
    +      checkAnswer(
    +        sql("SELECT employeeID, employeeName FROM part_table WHERE c = '1' 
AND d = '1'"),
    +        testResults)
    +
    +      sql(s"""LOAD DATA LOCAL INPATH "$testData" INTO TABLE part_table 
PARTITION(c="1", d="2")""")
    +      checkAnswer(
    +        sql("SELECT employeeID, employeeName FROM part_table WHERE c = '1' 
AND d = '2'"),
    +        testResults)
    +
    +      sql(s"""LOAD DATA LOCAL INPATH "$testData" INTO TABLE part_table 
PARTITION(c="2", d="2")""")
    +      checkAnswer(
    +        sql("SELECT employeeID, employeeName FROM part_table WHERE c = '2' 
AND d = '2'"),
    +        testResults)
    +
    +      intercept[ParseException] {
    +        sql("TRUNCATE TABLE part_table PARTITION(c='1', d='1') COLUMNS 
(employeeID)")
    +      }
    +
    +      sql("TRUNCATE TABLE part_table PARTITION(c='1', d='1')")
    --- End diff --
    
    Is it also possible to test one no-empty partition?


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