Fix a bug in CachingIndexCollectionManager (#464)

This commit is contained in:
Chungmin Lee 2021-06-18 03:38:50 +09:00 коммит произвёл GitHub
Родитель 08076c09b7
Коммит 036ecfdcfb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 30 добавлений и 5 удалений

Просмотреть файл

@ -59,11 +59,14 @@ class CachingIndexCollectionManager(
* @return list of indexes whose current state is among desired states
*/
override def getIndexes(states: Seq[String] = Seq()): Seq[IndexLogEntry] = {
indexCache.get().getOrElse {
val originalIndexes = super.getIndexes(states)
indexCache.set(originalIndexes)
originalIndexes
}
indexCache
.get()
.getOrElse {
val originalIndexes = super.getIndexes()
indexCache.set(originalIndexes)
originalIndexes
}
.filter(index => states.isEmpty || states.contains(index.state))
}
/**

Просмотреть файл

@ -978,6 +978,28 @@ class E2EHyperspaceRulesTest extends QueryTest with HyperspaceSuite {
}
}
test("Deleted indexes should not be applied.") {
spark.enableHyperspace()
val df = spark.read.parquet(nonPartitionedDataPath)
hyperspace.createIndex(df, IndexConfig("myind", Seq("c1"), Seq("c2")))
def query: DataFrame = df.filter("c1 == '2019-10-03'").select("c2")
assert(query.queryExecution.simpleString.contains("FileScan Hyperspace"))
hyperspace.deleteIndex("myind")
assert(hyperspace.indexes.filter("name == 'myind' and state == 'DELETED'").count() === 1)
assert(!query.queryExecution.simpleString.contains("FileScan Hyperspace"))
}
test("Deleted indexes should be shown as deleted.") {
spark.enableHyperspace()
val df = spark.read.parquet(nonPartitionedDataPath)
hyperspace.createIndex(df, IndexConfig("myind", Seq("c1"), Seq("c2")))
def query: DataFrame = df.filter("c1 == '2019-10-03'").select("c2")
assert(query.queryExecution.simpleString.contains("FileScan Hyperspace"))
hyperspace.deleteIndex("myind")
assert(!query.queryExecution.simpleString.contains("FileScan Hyperspace"))
assert(hyperspace.indexes.filter("name == 'myind' and state == 'DELETED'").count() === 1)
}
/**
* Verify that the query plan has the expected rootPaths.
*