Skip to content

Commit

Permalink
Add more IT
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Dai <[email protected]>
  • Loading branch information
dai-chen committed Sep 27, 2023
1 parent 3d7de22 commit 84bf793
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait FlintSparkCoveringIndexAstBuilder extends FlintSparkSqlExtensionsVisitor[A
ctx: CreateCoveringIndexStatementContext): Command = {
FlintSparkSqlCommand() { flint =>
val indexName = ctx.indexName.getText
val tableName = ctx.tableName.getText
val tableName = getFullTableName(flint, ctx.tableName)
val indexBuilder =
flint
.coveringIndex()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,46 @@ class FlintSparkCoveringIndexSqlITSuite extends FlintSparkSuite {
indexData.count() shouldBe 2
}

test("create covering index on table without database name") {
sql(s"CREATE INDEX $testIndex ON covering_sql_test (name)")

flint.describeIndex(testFlintIndex) shouldBe defined
}

test("create covering index on table in other database") {
sql("CREATE SCHEMA sample")
sql("USE sample")

// Create index without database name specified
sql("CREATE TABLE test1 (name STRING) USING CSV")
sql(s"CREATE INDEX $testIndex ON sample.test1 (name)")

// Create index with database name specified
sql("CREATE TABLE test2 (name STRING) USING CSV")
sql(s"CREATE INDEX $testIndex ON sample.test2 (name)")

try {
flint.describeIndex(s"flint_spark_catalog_sample_test1_${testIndex}_index") shouldBe defined
flint.describeIndex(s"flint_spark_catalog_sample_test2_${testIndex}_index") shouldBe defined
} finally {
sql("DROP DATABASE sample CASCADE")
}
}

test("create covering index on table in other database than current") {
sql("CREATE SCHEMA sample")
sql("USE sample")

// Specify database "default" in table name instead of current "sample" database
sql(s"CREATE INDEX $testIndex ON $testTable (name)")

try {
flint.describeIndex(testFlintIndex) shouldBe defined
} finally {
sql("DROP DATABASE sample CASCADE")
}
}

test("show all covering index on the source table") {
flint
.coveringIndex()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,43 @@ class FlintSparkSkippingIndexSqlITSuite extends FlintSparkSuite {
}

test("create skipping index on table without database name") {
sql(s"""
| CREATE SKIPPING INDEX ON skipping_sql_test
| (
| year PARTITION,
| name VALUE_SET,
| age MIN_MAX
| )
| """.stripMargin)
sql("CREATE SKIPPING INDEX ON skipping_sql_test ( year PARTITION )")

flint.describeIndex(testIndex) shouldBe defined
}

test("create skipping index on table in other database") {
sql("CREATE SCHEMA sample")
sql("USE sample")
sql("CREATE TABLE test (name STRING) USING CSV")
sql("CREATE SKIPPING INDEX ON test (name VALUE_SET)")

flint.describeIndex("flint_spark_catalog_sample_test_skipping_index") shouldBe defined
// Create index without database name specified
sql("CREATE TABLE test1 (name STRING) USING CSV")
sql("CREATE SKIPPING INDEX ON test1 (name VALUE_SET)")

// Create index with database name specified
sql("CREATE TABLE test2 (name STRING) USING CSV")
sql("CREATE SKIPPING INDEX ON sample.test2 (name VALUE_SET)")

try {
flint.describeIndex("flint_spark_catalog_sample_test1_skipping_index") shouldBe defined
flint.describeIndex("flint_spark_catalog_sample_test2_skipping_index") shouldBe defined
} finally {
sql("DROP DATABASE sample CASCADE")
}
}

test("create skipping index on table in other database than current") {
sql("CREATE SCHEMA sample")
sql("USE sample")

// Specify database "default" in table name instead of current "sample" database
sql(s"CREATE SKIPPING INDEX ON $testTable (name VALUE_SET)")

try {
flint.describeIndex(testIndex) shouldBe defined
} finally {
sql("DROP DATABASE sample CASCADE")
}
}

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

0 comments on commit 84bf793

Please sign in to comment.