Skip to content

Commit

Permalink
Add index type to show statement output
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Dai <[email protected]>
  • Loading branch information
dai-chen committed Oct 20, 2023
1 parent 4a54dd5 commit 7e16705
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ trait FlintSparkIndexJobAstBuilder extends FlintSparkSqlExtensionsVisitor[AnyRef

override def visitShowIndexJobStatement(ctx: ShowIndexJobStatementContext): AnyRef = {
val outputSchema = Seq(
AttributeReference("job name", StringType, nullable = false)(),
AttributeReference("index name", StringType, nullable = false)(),
AttributeReference("job_name", StringType, nullable = false)(),
AttributeReference("index_type", StringType, nullable = false)(),
AttributeReference("index_name", StringType, nullable = false)(),
AttributeReference("source", StringType, nullable = false)(),
AttributeReference("properties", StringType, nullable = false)())

Expand All @@ -35,7 +36,12 @@ trait FlintSparkIndexJobAstBuilder extends FlintSparkSqlExtensionsVisitor[AnyRef
.collect {
case index: FlintSparkIndex if index.options.autoRefresh() =>
val metadata = index.metadata()
Row(index.name(), metadata.name, metadata.source, jsonify(metadata.properties))
Row(
index.name(),
metadata.kind,
metadata.name,
metadata.source,
jsonify(metadata.properties))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ package org.opensearch.flint.spark
import java.io.File

import org.opensearch.flint.spark.covering.FlintSparkCoveringIndex
import org.opensearch.flint.spark.covering.FlintSparkCoveringIndex.COVERING_INDEX_TYPE
import org.opensearch.flint.spark.mv.FlintSparkMaterializedView
import org.opensearch.flint.spark.mv.FlintSparkMaterializedView.MV_INDEX_TYPE
import org.opensearch.flint.spark.skipping.FlintSparkSkippingIndex
import org.opensearch.flint.spark.skipping.FlintSparkSkippingIndex.SKIPPING_INDEX_TYPE

import org.apache.spark.sql.Row

Expand Down Expand Up @@ -45,23 +48,23 @@ class FlintSparkIndexJobSqlITSuite extends FlintSparkSuite {
startSkippingIndexJob()
checkAnswer(
sql("SHOW INDEX JOBS"),
Seq(Row(testSkippingIndex, "", testTable, "{}")))
Seq(Row(testSkippingIndex, SKIPPING_INDEX_TYPE, "", testTable, "{}")))

startCoveringIndexJob()
checkAnswer(
sql("SHOW INDEX JOBS"),
Seq(
Row(testSkippingIndex, "", testTable, "{}"),
Row(testCoveringIndex, testIndex, testTable, "{}")))
Row(testSkippingIndex, SKIPPING_INDEX_TYPE, "", testTable, "{}"),
Row(testCoveringIndex, COVERING_INDEX_TYPE, testIndex, testTable, "{}")))

withTempDir { checkpointDir =>
startMaterializedViewIndexJob(checkpointDir)
checkAnswer(
sql("SHOW INDEX JOBS"),
Seq(
Row(testSkippingIndex, "", testTable, "{}"),
Row(testCoveringIndex, testIndex, testTable, "{}"),
Row(testMvIndex, testMv, testMvQuery, "{}")))
Row(testSkippingIndex, SKIPPING_INDEX_TYPE, "", testTable, "{}"),
Row(testCoveringIndex, COVERING_INDEX_TYPE, testIndex, testTable, "{}"),
Row(testMvIndex, MV_INDEX_TYPE, testMv, testMvQuery, "{}")))
}
}

Expand Down

0 comments on commit 7e16705

Please sign in to comment.