[GitHub] [hudi] XuQianJin-Stars commented on a change in pull request #4455: [HUDI-3108] Fix Purge Drop MOR Table Cause error
XuQianJin-Stars commented on a change in pull request #4455: URL: https://github.com/apache/hudi/pull/4455#discussion_r775731656 ## File path: hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/DropHoodieTableCommand.scala ## @@ -85,25 +91,42 @@ case class DropHoodieTableCommand( } private def dropHiveDataSourceTable( -sparkSession: SparkSession, -table: CatalogTable, -ifExists: Boolean, -purge: Boolean): Unit = { + sparkSession: SparkSession, + hoodieCatalogTable: HoodieCatalogTable): Unit = { +val table = hoodieCatalogTable.table val dbName = table.identifier.database.get val tableName = table.identifier.table + // check database exists val dbExists = sparkSession.sessionState.catalog.databaseExists(dbName) if (!dbExists) { throw new NoSuchDatabaseException(dbName) } -// check table exists -if (!sparkSession.sessionState.catalog.tableExists(table.identifier)) { - throw new NoSuchTableException(dbName, table.identifier.table) + +if (HoodieTableType.MERGE_ON_READ == hoodieCatalogTable.tableType && purge) { + val snapshotTableName = hoodieCatalogTable.tableName + SUFFIX_SNAPSHOT_TABLE + val roTableName = hoodieCatalogTable.tableName + SUFFIX_READ_OPTIMIZED_TABLE + + dropHiveTable(sparkSession, dbName, snapshotTableName) + dropHiveTable(sparkSession, dbName, roTableName) + dropHiveTable(sparkSession, dbName, hoodieCatalogTable.tableName, purge) Review comment: > why still need the original tableName? Because purge deletes the directory of the original table. Spark's mor table has the original table first, and two other tables are created when inserting data. -- 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-unsubscr...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [hudi] XuQianJin-Stars commented on a change in pull request #4455: [HUDI-3108] Fix Purge Drop MOR Table Cause error
XuQianJin-Stars commented on a change in pull request #4455: URL: https://github.com/apache/hudi/pull/4455#discussion_r775731656 ## File path: hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/DropHoodieTableCommand.scala ## @@ -85,25 +91,42 @@ case class DropHoodieTableCommand( } private def dropHiveDataSourceTable( -sparkSession: SparkSession, -table: CatalogTable, -ifExists: Boolean, -purge: Boolean): Unit = { + sparkSession: SparkSession, + hoodieCatalogTable: HoodieCatalogTable): Unit = { +val table = hoodieCatalogTable.table val dbName = table.identifier.database.get val tableName = table.identifier.table + // check database exists val dbExists = sparkSession.sessionState.catalog.databaseExists(dbName) if (!dbExists) { throw new NoSuchDatabaseException(dbName) } -// check table exists -if (!sparkSession.sessionState.catalog.tableExists(table.identifier)) { - throw new NoSuchTableException(dbName, table.identifier.table) + +if (HoodieTableType.MERGE_ON_READ == hoodieCatalogTable.tableType && purge) { + val snapshotTableName = hoodieCatalogTable.tableName + SUFFIX_SNAPSHOT_TABLE + val roTableName = hoodieCatalogTable.tableName + SUFFIX_READ_OPTIMIZED_TABLE + + dropHiveTable(sparkSession, dbName, snapshotTableName) + dropHiveTable(sparkSession, dbName, roTableName) + dropHiveTable(sparkSession, dbName, hoodieCatalogTable.tableName, purge) Review comment: > why still need the original tableName? Because purge deletes the directory of the original table. -- 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-unsubscr...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org