Skip to content

Commit

Permalink
Fix show index with skipping index bug
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Dai <[email protected]>
  • Loading branch information
dai-chen committed Sep 19, 2023
1 parent dfc9720 commit bd3f053
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ trait FlintSparkCoveringIndexAstBuilder extends FlintSparkSqlExtensionsVisitor[C
val indexNamePattern = FlintSparkCoveringIndex.getFlintIndexName("*", fullTableName)
flint
.describeIndexes(indexNamePattern)
.map { case index: FlintSparkCoveringIndex => Row(index.indexName) }
.collect { case index: FlintSparkCoveringIndex =>
Row(index.indexName)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package org.opensearch.flint.spark
import scala.Option.empty

import org.opensearch.flint.spark.covering.FlintSparkCoveringIndex.getFlintIndexName
import org.opensearch.flint.spark.skipping.FlintSparkSkippingIndex.getSkippingIndexName
import org.scalatest.matchers.must.Matchers.defined
import org.scalatest.matchers.should.Matchers.convertToAnyShouldWrapper

Expand Down Expand Up @@ -73,17 +74,27 @@ class FlintSparkCoveringIndexSqlITSuite extends FlintSparkSuite {
.onTable(testTable)
.addIndexColumns("name", "age")
.create()

// Create another covering index
flint
.coveringIndex()
.name("idx_address")
.onTable(testTable)
.addIndexColumns("address")
.create()

// Create a skipping index which is expected to be filtered
flint
.skippingIndex()
.onTable(testTable)
.addPartitions("year", "month")
.create()

val result = sql(s"SHOW INDEX ON $testTable")
checkAnswer(result, Seq(Row(testIndex), Row("idx_address")))

flint.deleteIndex(getFlintIndexName("idx_address", testTable))
flint.deleteIndex(getSkippingIndexName(testTable))
}

test("describe covering index") {
Expand Down

0 comments on commit bd3f053

Please sign in to comment.