You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by GitBox <gi...@apache.org> on 2021/01/21 08:43:46 UTC

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #4076: [CARBONDATA-4107] Added mvExists property for MV fact table and added lock while touchMDTFile

Indhumathi27 commented on a change in pull request #4076:
URL: https://github.com/apache/carbondata/pull/4076#discussion_r561693339



##########
File path: integration/spark/src/main/scala/org/apache/spark/sql/execution/command/view/CarbonDropMVCommand.scala
##########
@@ -90,6 +95,37 @@ case class CarbonDropMVCommand(
           }
         }
 
+        // Update the mvExists and related databases property to mv fact tables
+        schema.getRelatedTables.asScala.foreach { table =>
+          val dbName = table.getDatabaseName
+          val tableName = table.getTableName
+          try {
+            val carbonTable =
+              CarbonEnv.getCarbonTable(Some(dbName), tableName)(session)
+            val relatedMVTablesMap = carbonTable.getMVTablesMap
+            // check if database has materialized views or not
+            val anotherMVExistsInDb = viewManager.getSchemas(databaseName).asScala.exists {
+              mvSchema =>
+                mvSchema.getRelatedTables.asScala.exists(_.getTableName.equalsIgnoreCase(tableName))
+            }
+            if (!anotherMVExistsInDb) {
+              //  If database dont have any MV, then remove the database from related tables
+              //  property and update table property of fact table
+              relatedMVTablesMap.get(databaseName).remove(name)
+              if (relatedMVTablesMap.get(databaseName).isEmpty) {
+                relatedMVTablesMap.remove(databaseName)
+              }
+              CarbonIndexUtil.addOrModifyTableProperty(carbonTable,
+                Map("relatedMVTablesMap".toLowerCase -> new Gson().toJson(relatedMVTablesMap)),
+                needLock = false)(session)
+              CarbonHiveIndexMetadataUtil.refreshTable(dbName, tableName, session)
+            }
+          } catch {
+            case _: Exception =>
+            // ignore as table is a non-carbon table

Review comment:
       This Exception is added, because for parquet and orc, carbon table will not be present. 




----------------------------------------------------------------
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:
users@infra.apache.org