dongjoon-hyun commented on code in PR #59733:
URL: https://github.com/apache/spark/pull/59733#discussion_r4360323531


##########
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala:
##########
@@ -629,6 +629,67 @@ class HiveDDLSuite
     }
   }
 
+  test("SPARK-60492: Keep Hive incompatible partition columns in alterTable 
and renameTable") {
+    Seq(
+      ("TIMESTAMP_NTZ", "TIMESTAMP_NTZ '2018-11-17 13:33:33'",
+        LocalDateTime.of(2018, 11, 17, 13, 33, 33)),
+      ("TIME", "TIME '12:34:56'", LocalTime.of(12, 34, 56))
+    ).foreach { case (dataType, literal, value) =>
+      def checkTable(partitionColumnNames: Seq[String]): Unit = {
+        val table = 
spark.sessionState.catalog.getTableMetadata(TableIdentifier("t2"))
+        assert(table.properties.get("k").contains("v"))
+        assert(table.partitionColumnNames == partitionColumnNames)
+        checkAnswer(spark.table("t2"), Row(1, "a", value))
+      }
+      withTable("t", "t2") {
+        sql(s"CREATE TABLE t (i INT, pt $dataType) USING PARQUET PARTITIONED 
BY (pt)")
+        // This stores the data columns in Hive metastore as they are Hive 
compatible.
+        sql("ALTER TABLE t ADD COLUMNS (c STRING)")
+        sql("ALTER TABLE t SET TBLPROPERTIES ('k' = 'v')")
+        sql(s"INSERT INTO t SELECT 1, 'a', $literal")
+        sql("MSCK REPAIR TABLE t")
+        sql("ALTER TABLE t RENAME TO t2")
+        checkTable(Seq("pt"))
+      }
+      withTable("t", "t2") {
+        sql(s"CREATE TABLE t (i INT, P1 STRING, P2 $dataType) USING PARQUET " +
+          "PARTITIONED BY (P1, P2)")

Review Comment:
   Thank you. I added a test case where the Hive incompatible partition column 
comes first, `PARTITIONED BY (P2, P1)`.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to