wangyum commented on a change in pull request #27538: [SPARK-30785][SQL] Create 
table like should keep tracksPartitionsInCatalog same with source table
URL: https://github.com/apache/spark/pull/27538#discussion_r378632769
 
 

 ##########
 File path: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
 ##########
 @@ -2724,4 +2730,18 @@ class HiveDDLSuite
       }
     }
   }
+
+  test("SPARK-30785: create table like a partitioned table") {
+    val catalog = spark.sessionState.catalog
+    withTable("sc_part", "ta_part") {
+      sql("CREATE TABLE sc_part (key string, ts int) USING parquet PARTITIONED 
BY (ts)")
+      sql("CREATE TABLE ta_part like sc_part")
+      val sourceTable = catalog.getTableMetadata(TableIdentifier("sc_part", 
Some("default")))
+      val targetTable = catalog.getTableMetadata(TableIdentifier("ta_part", 
Some("default")))
+      assert(sourceTable.tracksPartitionsInCatalog)
+      assert(sourceTable.tracksPartitionsInCatalog == 
targetTable.tracksPartitionsInCatalog)
+      assert(targetTable.partitionColumnNames == Seq("ts"))
+      sql("ALTER TABLE ta_part ADD PARTITION (ts=10)") // no exception
+    }
 
 Review comment:
   Add another assert?
   ```scala
   checkAnswer(sql("SHOW PARTITIONS sc_part"), Row("ts=10") :: Nil) or 
assert(spark.sql("SHOW PARTITIONS sc_part").count() == 1)
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to