Skip to content

Commit

Permalink
Add skip type in desc output
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Dai <daichen@amazon.com>
  • Loading branch information
dai-chen committed Jun 27, 2023
1 parent 719a953 commit becdf5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ class FlintSparkSqlAstBuilder extends FlintSparkSqlExtensionsBaseVisitor[Command
ctx: DescribeSkippingIndexStatementContext): Command = {
val outputSchema = Seq(
AttributeReference("indexed_col_name", StringType, nullable = false)(),
AttributeReference("data_type", StringType, nullable = false)())
AttributeReference("data_type", StringType, nullable = false)(),
AttributeReference("skip_type", StringType, nullable = false)())

FlintSparkSqlCommand(outputSchema) { flint =>
val indexName = getSkippingIndexName(ctx.tableName.getText)
flint
.describeIndex(indexName)
.map { case index: FlintSparkSkippingIndex =>
index.indexedColumns.map(strategy => Row(strategy.columnName, strategy.columnType))
index.indexedColumns.map(strategy =>
Row(strategy.columnName, strategy.columnType, strategy.kind.toString))
}
.getOrElse(Seq.empty)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class FlintSparkSqlSuite extends QueryTest with FlintSuite with OpenSearchSuite

override def beforeAll(): Unit = {
super.beforeAll()

sql(s"""
| CREATE TABLE $testTable
| (
| name STRING
| name STRING,
| age INT
| )
| USING CSV
| OPTIONS (
Expand All @@ -50,25 +50,29 @@ class FlintSparkSqlSuite extends QueryTest with FlintSuite with OpenSearchSuite

protected override def beforeEach(): Unit = {
super.beforeEach()

flint
.skippingIndex()
.onTable(testTable)
.addPartitions("year")
.addValueSet("name")
.addMinMax("age")
.create()
}

protected override def afterEach(): Unit = {
super.afterEach()

flint.deleteIndex(testIndex)
}

test("describe skipping index") {
val result = sql(s"DESC SKIPPING INDEX ON $testTable")

checkAnswer(result, Seq(Row("year", "int"), Row("name", "string")))
checkAnswer(
result,
Seq(
Row("year", "int", "Partition"),
Row("name", "string", "ValuesSet"),
Row("age", "int", "MinMax")))
}

test("should return empty if no skipping index to describe") {
Expand Down

0 comments on commit becdf5f

Please sign in to comment.