Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -856,9 +856,20 @@ private[hive] class HiveClientImpl(
}

def reset(): Unit = withHiveState {
client.getAllTables("default").asScala.foreach { 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have the same issue for Hive indexes? Also, we normally also added a test case in the Version Suite. You can do it by using the method runSqlHive(sql: String) to create materialized views.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test in another PR: #23992

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue only occurs with materialized views in Hive 3.1.
I have tested the index and the view.

mvs.foreach { table =>
val t = table.getTableName
logDebug(s"Deleting materialized view $t")
client.dropTable("default", t)
}

others.foreach { table =>
val t = table.getTableName
logDebug(s"Deleting table $t")
val table = client.getTable("default", t)
try {
client.getIndexes("default", t, 255).asScala.foreach { index =>
shim.dropIndex(client, "default", t, index.getIndexName)
Expand Down