Skip to content

Commit

Permalink
Add nested column test
Browse files Browse the repository at this point in the history
Signed-off-by: Rupal Mahajan <[email protected]>
  • Loading branch information
rupal-bq committed Apr 2, 2024
1 parent bbc8ca4 commit e09ab39
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ DROP SKIPPING INDEX ON <object>

VACUUM SKIPPING INDEX ON <object>

ANALYZE SKIPPING INDEX ON <object>
ANALYZE SKIPPING INDEX ON <object> ( column [, ...] )

<object> ::= [db_name].[schema_name].table_name
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,21 @@ class FlintSparkSkippingIndexSqlITSuite extends FlintSparkSuite {
"MIN_MAX data structure is recommended for IntegerType columns")))
}

test("analyze skipping index with nested column") {
val structTableName = "spark_catalog.default.struct_column_test"
createStructFieldTable(structTableName)
val result = sql(s"ANALYZE SKIPPING INDEX ON $structTableName(info.name)")

checkAnswer(
result,
Seq(
Row(
"name",
"string",
"BLOOM_FILTER",
"BLOOM_FILTER data structure is recommended for StringType columns")))
}

test("analyze skipping index on invalid table") {
the[IllegalStateException] thrownBy {
sql(s"ANALYZE SKIPPING INDEX ON testTable")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,23 @@ trait FlintSparkSuite extends QueryTest with FlintSuite with OpenSearchSuite wit
| )
|)""".stripMargin)
}

protected def createStructFieldTable(testTable: String): Unit = {
sql(s"""
| CREATE TABLE $testTable (
| id INT,
| info STRUCT<
| name: STRING,
| age: INT>)
| USING json
|""".stripMargin)

sql(s"""
| INSERT INTO $testTable
| VALUES
| (1, STRUCT('Alice', 30)),
| (2, STRUCT('Bob', 25)),
| (3, STRUCT('Charlie', 35))
| """.stripMargin)
}
}

0 comments on commit e09ab39

Please sign in to comment.