diff --git a/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/sql/covering/FlintSparkCoveringIndexAstBuilder.scala b/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/sql/covering/FlintSparkCoveringIndexAstBuilder.scala index c2be3f806..203ebc22c 100644 --- a/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/sql/covering/FlintSparkCoveringIndexAstBuilder.scala +++ b/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/sql/covering/FlintSparkCoveringIndexAstBuilder.scala @@ -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) + } } } diff --git a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkCoveringIndexSqlITSuite.scala b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkCoveringIndexSqlITSuite.scala index f0c624dfe..66d19a261 100644 --- a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkCoveringIndexSqlITSuite.scala +++ b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkCoveringIndexSqlITSuite.scala @@ -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 @@ -73,6 +74,8 @@ class FlintSparkCoveringIndexSqlITSuite extends FlintSparkSuite { .onTable(testTable) .addIndexColumns("name", "age") .create() + + // Create another covering index flint .coveringIndex() .name("idx_address") @@ -80,10 +83,18 @@ class FlintSparkCoveringIndexSqlITSuite extends FlintSparkSuite { .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") {