You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2022/05/15 04:30:46 UTC

[GitHub] [hudi] jinxing64 commented on a diff in pull request #5564: [HUDI-4087] Support dropping RO and RT table in DropHoodieTableCommand

jinxing64 commented on code in PR #5564:
URL: https://github.com/apache/hudi/pull/5564#discussion_r873107281


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/command/DropHoodieTableCommand.scala:
##########
@@ -88,42 +86,33 @@ extends HoodieLeafRunnableCommand {
     }
   }
 
-  private def dropHiveDataSourceTable(
-       sparkSession: SparkSession,
-       hoodieCatalogTable: HoodieCatalogTable): Unit = {
-    val table = hoodieCatalogTable.table
-    val dbName = table.identifier.database.get
-    val tableName = hoodieCatalogTable.tableName
-
-    // check database exists
-    val dbExists = sparkSession.sessionState.catalog.databaseExists(dbName)
-    if (!dbExists) {
-      throw new NoSuchDatabaseException(dbName)
-    }
-
-    if (HoodieTableType.MERGE_ON_READ == hoodieCatalogTable.tableType && purge) {
-      val snapshotTableName = tableName + MOR_SNAPSHOT_TABLE_SUFFIX
-      val roTableName = tableName + MOR_READ_OPTIMIZED_TABLE_SUFFIX
-
-      dropHiveTable(sparkSession, dbName, snapshotTableName)
-      dropHiveTable(sparkSession, dbName, roTableName)
+  private def getTableRTAndRO(catalog: SessionCatalog,
+      hoodieTable: HoodieCatalogTable): (Option[CatalogTable], Option[CatalogTable]) = {
+    val rtIdt = hoodieTable.table.identifier.copy(
+      table = s"${hoodieTable.tableName}${MOR_SNAPSHOT_TABLE_SUFFIX}")
+    val roIdt = hoodieTable.table.identifier.copy(
+      table = s"${hoodieTable.tableName}${MOR_READ_OPTIMIZED_TABLE_SUFFIX}")
+
+    var rtTableOpt: Option[CatalogTable] = None
+    var roTableOpt: Option[CatalogTable] = None
+    if (catalog.tableExists(roIdt)) {

Review Comment:
   Sure ~



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org