ayudovin commented on a change in pull request #27030: [SPARK-30244][SQL] Emit 
pre/post events for "Partition" methods in ExternalCatalogWithListener
URL: https://github.com/apache/spark/pull/27030#discussion_r367779692
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/ExternalCatalogEventSuite.scala
 ##########
 @@ -209,4 +209,67 @@ class ExternalCatalogEventSuite extends SparkFunSuite {
     catalog.dropFunction("db5", "fn4")
     checkEvents(DropFunctionPreEvent("db5", "fn4") :: DropFunctionEvent("db5", 
"fn4") :: Nil)
   }
+
+  testWithCatalog("partition") { (catalog, checkEvents) =>
+    val path1 = Files.createTempDirectory("db_")
+    val path2 = Files.createTempDirectory(path1, "tbl_")
+    val uri1 = preparePath(path1)
+    val uri2 = preparePath(path2)
+
+    // CREATE
+    val dbDefinition = createDbDefinition(uri1)
+
+    val storage = CatalogStorageFormat.empty.copy(
+      locationUri = Option(uri2))
+
+    val tableDefinition = CatalogTable(
+      identifier = TableIdentifier("tbl1", Some("db5")),
+      tableType = CatalogTableType.MANAGED,
+      storage = storage,
+      schema = new StructType().add("id", "long"))
+
+    val partition = CatalogTablePartition(spec = 
CatalogTypes.emptyTablePartitionSpec,
+      storage = CatalogStorageFormat.empty)
+
+    catalog.createDatabase(dbDefinition, ignoreIfExists = false)
+    checkEvents(CreateDatabasePreEvent("db5") :: CreateDatabaseEvent("db5") :: 
Nil)
+
+    catalog.createTable(tableDefinition, ignoreIfExists = false)
+    checkEvents(CreateTablePreEvent("db5", "tbl1") :: CreateTableEvent("db5", 
"tbl1") :: Nil)
+
+    catalog.createPartitions("db5", "tbl1", Seq(partition), ignoreIfExists = 
false)
+    checkEvents(CreatePartitionPreEvent("db5", "tbl1", Seq(partition)) ::
+      CreatePartitionEvent("db5", "tbl1", Seq(partition)) :: Nil)
+
+    catalog.createPartitions("db5", "tbl1", Seq(partition), ignoreIfExists = 
true)
+    checkEvents(CreatePartitionPreEvent("db5", "tbl1", Seq(partition)) ::
+      CreatePartitionEvent("db5", "tbl1", Seq(partition)) :: Nil)
+
+    // RENAME
+    val newPartition = CatalogTablePartition(spec = Map("key1" -> "1", "key2" 
-> "2"),
+      storage = CatalogStorageFormat.empty)
+
+    catalog.renamePartitions("db5", "tbl1", Seq(partition.spec), 
Seq(newPartition.spec))
 
 Review comment:
   So, I could not find the real SQL statement for that, that's why I changed 
this unit tests.

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