You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/05/13 17:42:15 UTC

[GitHub] [spark] dongjoon-hyun commented on a change in pull request #24592: [SPARK-27690][SQL] Refactor HiveClientImpl#reset() to remove materialized view first

dongjoon-hyun commented on a change in pull request #24592: [SPARK-27690][SQL] Refactor HiveClientImpl#reset() to remove materialized view first
URL: https://github.com/apache/spark/pull/24592#discussion_r283458184
 
 

 ##########
 File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
 ##########
 @@ -856,20 +856,31 @@ private[hive] class HiveClientImpl(
   }
 
   def reset(): Unit = withHiveState {
-    client.getAllTables("default").asScala.foreach { t =>
-      logDebug(s"Deleting table $t")
-      val table = client.getTable("default", t)
+    val allTables = client.getAllTables("default")
+    val (mvs, others) = allTables.asScala.map(t => client.getTable("default", t))
+      .partition(_.getTableType.toString.equals("MATERIALIZED_VIEW"))
+
+    // Remove materialized view first, otherwise caused a violation of foreign key constraint.
+    mvs.foreach { table =>
+      val tableName = table.getTableName
+      logDebug(s"Deleting materialized view $tableName")
+      client.dropTable("default", table.getTableName)
+    }
+
+    others.foreach { table =>
 
 Review comment:
   `table` -> `t`.
   
   It's always good to reduce the unnecessary patch diff.
   

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org