akashrn5 commented on a change in pull request #3612: [CARBONDATA-3694] 
Separate Materialized View command from DataMap command
URL: https://github.com/apache/carbondata/pull/3612#discussion_r378976973
 
 

 ##########
 File path: 
datamap/mv/core/src/main/scala/org/apache/carbondata/mv/extension/command/RebuildMaterializedViewCommand.scala
 ##########
 @@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.carbondata.mv.extension.command
+
+import org.apache.spark.sql.{CarbonEnv, Row, SparkSession}
+import org.apache.spark.sql.catalyst.TableIdentifier
+import org.apache.spark.sql.execution.command.DataCommand
+
+import 
org.apache.carbondata.common.exceptions.sql.MalformedMaterializedViewException
+import org.apache.carbondata.core.datamap.DataMapStoreManager
+import org.apache.carbondata.core.datamap.status.DataMapStatusManager
+import org.apache.carbondata.core.util.CarbonProperties
+import org.apache.carbondata.datamap.DataMapManager
+import org.apache.carbondata.events.{UpdateDataMapPostExecutionEvent, _}
+
+/**
+ * Refresh Materialized View Command implementation
+ * This command refresh the MV table incrementally and make it synchronized 
with the main
+ * table. After sync, MV state is changed to enabled.
+ */
+case class RebuildMaterializedViewCommand(
+    mvName: String) extends DataCommand {
+
+  override def processData(sparkSession: SparkSession): Seq[Row] = {
+    import scala.collection.JavaConverters._
+    val schemas = DataMapStoreManager.getInstance().getAllDataMapSchemas
+    val schemaOption = schemas.asScala.find(p => 
p.getDataMapName.equalsIgnoreCase(mvName))
+    if (schemaOption.isEmpty) {
+        throw new MalformedMaterializedViewException(s"Materialized view 
$mvName does not exist")
+    }
+    val schema = schemaOption.get
 
 Review comment:
   rename to `datamapSchema`

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


With regards,
Apache Git Services

Reply via email to