Skip to content

Commit

Permalink
Add IT on Flint API and SQL
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 25, 2023
1 parent d808734 commit 6048236
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ class FlintSparkSkippingIndexITSuite extends FlintSparkSuite {
.options(FlintSparkIndexOptions(Map(
"auto_refresh" -> "true",
"refresh_interval" -> "1 Minute",
"checkpoint_location" -> "s3a://test/"
"checkpoint_location" -> "s3a://test/",
"index_settings" -> "{\"number_of_shards\": 3,\"number_of_replicas\": 2}"
)))
.create()

Expand All @@ -124,6 +125,8 @@ class FlintSparkSkippingIndexITSuite extends FlintSparkSuite {
index.get.options.autoRefresh() shouldBe true
index.get.options.refreshInterval() shouldBe Some("1 Minute")
index.get.options.checkpointLocation() shouldBe Some("s3a://test/")
index.get.options.indexSettings() shouldBe
"{\"number_of_shards\": 3,\"number_of_replicas\": 2}"
}

test("should not have ID column in index data") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
package org.opensearch.flint.spark

import scala.Option.empty
import scala.collection.JavaConverters.mapAsJavaMapConverter

import org.json4s.{Formats, NoTypeHints}
import org.json4s.native.JsonMethods.parse
import org.json4s.native.Serialization
import org.opensearch.flint.core.FlintOptions
import org.opensearch.flint.core.storage.FlintOpenSearchClient
import org.opensearch.flint.spark.skipping.FlintSparkSkippingIndex.getSkippingIndexName
import org.scalatest.matchers.must.Matchers.defined
import org.scalatest.matchers.should.Matchers.convertToAnyShouldWrapper
Expand Down Expand Up @@ -75,6 +81,24 @@ class FlintSparkSkippingIndexSqlITSuite extends FlintSparkSuite {
}
}

test("create skipping index with index settings") {
sql(s"""
| CREATE SKIPPING INDEX ON $testTable
| ( year PARTITION )
| WITH (
| index_settings = '{"number_of_shards": 3, "number_of_replicas": 2}'
| )
|""".stripMargin)

// Check if the index settings is set to OS index
val flintClient = new FlintOpenSearchClient(new FlintOptions(openSearchOptions.asJava))

implicit val formats: Formats = Serialization.formats(NoTypeHints)
val settings = parse(flintClient.getIndexMetadata(testIndex).getIndexSettings)
(settings \ "index.number_of_shards").extract[String] shouldBe "3"
(settings \ "index.number_of_replicas").extract[String] shouldBe "2"
}

test("create skipping index with manual refresh") {
sql(s"""
| CREATE SKIPPING INDEX ON $testTable
Expand Down

0 comments on commit 6048236

Please sign in to comment.