From 7e167053c6fe382623b33f5acb2ca592fe24e9a7 Mon Sep 17 00:00:00 2001 From: Chen Dai Date: Thu, 19 Oct 2023 12:08:57 -0700 Subject: [PATCH] Add index type to show statement output Signed-off-by: Chen Dai --- .../sql/job/FlintSparkIndexJobAstBuilder.scala | 12 +++++++++--- .../spark/FlintSparkIndexJobSqlITSuite.scala | 15 +++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/sql/job/FlintSparkIndexJobAstBuilder.scala b/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/sql/job/FlintSparkIndexJobAstBuilder.scala index b05dd4603..7492e8edb 100644 --- a/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/sql/job/FlintSparkIndexJobAstBuilder.scala +++ b/flint-spark-integration/src/main/scala/org/opensearch/flint/spark/sql/job/FlintSparkIndexJobAstBuilder.scala @@ -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)()) @@ -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)) } } } diff --git a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkIndexJobSqlITSuite.scala b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkIndexJobSqlITSuite.scala index 2483ce978..c94f47eff 100644 --- a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkIndexJobSqlITSuite.scala +++ b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkIndexJobSqlITSuite.scala @@ -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 @@ -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, "{}"))) } }