Fix a bug in CachingIndexCollectionManager (#464)
This commit is contained in:
Родитель
08076c09b7
Коммит
036ecfdcfb
|
@ -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.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче