Skip to content

Commit 0bd2eeb

Browse files
authored
[Vended Dashboards] Enable config of meta data cache by default (#1123)
* [Vended Dashboards] Enable config of meta data cache for vended dashboards refresh Signed-off-by: Jialiang Liang <jiallian@amazon.com> * fix the IT Signed-off-by: Jialiang Liang <jiallian@amazon.com> * fix the lint Signed-off-by: Jialiang Liang <jiallian@amazon.com> --------- Signed-off-by: Jialiang Liang <jiallian@amazon.com>
1 parent 8f18277 commit 0bd2eeb

File tree

3 files changed

+53
-58
lines changed

3 files changed

+53
-58
lines changed

flint-spark-integration/src/main/scala/org/apache/spark/sql/flint/config/FlintSparkConf.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ object FlintSparkConf {
314314
.createOptional()
315315
val METADATA_CACHE_WRITE = FlintConfig("spark.flint.metadataCacheWrite.enabled")
316316
.doc("Enable Flint metadata cache write to Flint index mappings")
317-
.createWithDefault("false")
317+
.createWithDefault("true")
318318

319319
val CUSTOM_SESSION_MANAGER =
320320
FlintConfig("spark.flint.job.customSessionManager")

flint-spark-integration/src/test/scala/org/apache/spark/FlintSuite.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ trait FlintSuite extends SharedSparkSession {
6363
}
6464
}
6565

66-
protected def withMetadataCacheWriteEnabled(block: => Unit): Unit = {
67-
setFlintSparkConf(METADATA_CACHE_WRITE, "true")
66+
protected def withMetadataCacheWriteDisabled(block: => Unit): Unit = {
67+
setFlintSparkConf(METADATA_CACHE_WRITE, "false")
6868
try {
6969
block
7070
} finally {
71-
setFlintSparkConf(METADATA_CACHE_WRITE, "false")
71+
setFlintSparkConf(METADATA_CACHE_WRITE, "true")
7272
}
7373
}
7474

integ-test/src/integration/scala/org/opensearch/flint/spark/metadatacache/FlintOpenSearchMetadataCacheWriterITSuite.scala

+49-54
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat
6363
}
6464

6565
test("build disabled metadata cache writer") {
66-
FlintMetadataCacheWriterBuilder
67-
.build(FlintSparkConf()) shouldBe a[FlintDisabledMetadataCacheWriter]
66+
withMetadataCacheWriteDisabled {
67+
FlintMetadataCacheWriterBuilder
68+
.build(FlintSparkConf()) shouldBe a[FlintDisabledMetadataCacheWriter]
69+
}
6870
}
6971

7072
test("build opensearch metadata cache writer") {
71-
withMetadataCacheWriteEnabled {
72-
FlintMetadataCacheWriterBuilder
73-
.build(FlintSparkConf()) shouldBe a[FlintOpenSearchMetadataCacheWriter]
74-
}
73+
FlintMetadataCacheWriterBuilder
74+
.build(FlintSparkConf()) shouldBe a[FlintOpenSearchMetadataCacheWriter]
7575
}
7676

7777
test("write metadata cache to index mappings") {
@@ -345,67 +345,62 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat
345345
|""".stripMargin)).foreach { case (refreshMode, optionsMap, expectedJson) =>
346346
test(s"write metadata cache for $refreshMode") {
347347
withExternalSchedulerEnabled {
348-
withMetadataCacheWriteEnabled {
349-
val flint: FlintSpark = new FlintSpark(spark)
350-
withTempDir { checkpointDir =>
351-
// update checkpoint_location if available in optionsMap
352-
val indexOptions = FlintSparkIndexOptions(
353-
optionsMap
354-
.get("checkpoint_location")
355-
.map(_ =>
356-
optionsMap.updated("checkpoint_location", checkpointDir.getAbsolutePath))
357-
.getOrElse(optionsMap))
358-
359-
flint
360-
.skippingIndex()
361-
.onTable(testTable)
362-
.addMinMax("age")
363-
.options(indexOptions, testFlintIndex)
364-
.create()
365-
366-
val propertiesJson = compact(render(getPropertiesJValue(testFlintIndex)))
367-
propertiesJson should matchJson(expectedJson)
368-
369-
flint.refreshIndex(testFlintIndex)
370-
val lastRefreshTime =
371-
compact(render(getPropertiesJValue(testFlintIndex) \ "lastRefreshTime")).toLong
372-
lastRefreshTime should be > 0L
373-
}
348+
val flint: FlintSpark = new FlintSpark(spark)
349+
withTempDir { checkpointDir =>
350+
// update checkpoint_location if available in optionsMap
351+
val indexOptions = FlintSparkIndexOptions(
352+
optionsMap
353+
.get("checkpoint_location")
354+
.map(_ => optionsMap.updated("checkpoint_location", checkpointDir.getAbsolutePath))
355+
.getOrElse(optionsMap))
356+
357+
flint
358+
.skippingIndex()
359+
.onTable(testTable)
360+
.addMinMax("age")
361+
.options(indexOptions, testFlintIndex)
362+
.create()
363+
364+
val propertiesJson = compact(render(getPropertiesJValue(testFlintIndex)))
365+
propertiesJson should matchJson(expectedJson)
366+
367+
flint.refreshIndex(testFlintIndex)
368+
val lastRefreshTime =
369+
compact(render(getPropertiesJValue(testFlintIndex) \ "lastRefreshTime")).toLong
370+
lastRefreshTime should be > 0L
374371
}
375372
}
376373
}
377374
}
378375

379376
test("write metadata cache for auto refresh index with internal scheduler") {
380-
withMetadataCacheWriteEnabled {
381-
val flint: FlintSpark = new FlintSpark(spark)
382-
withTempDir { checkpointDir =>
383-
flint
384-
.skippingIndex()
385-
.onTable(testTable)
386-
.addMinMax("age")
387-
.options(
388-
FlintSparkIndexOptions(
389-
Map(
390-
"auto_refresh" -> "true",
391-
"scheduler_mode" -> "internal",
392-
"refresh_interval" -> "10 Minute",
393-
"checkpoint_location" -> checkpointDir.getAbsolutePath)),
394-
testFlintIndex)
395-
.create()
396-
397-
val propertiesJson = compact(render(getPropertiesJValue(testFlintIndex)))
398-
propertiesJson should matchJson(s"""
377+
val flint: FlintSpark = new FlintSpark(spark)
378+
withTempDir { checkpointDir =>
379+
flint
380+
.skippingIndex()
381+
.onTable(testTable)
382+
.addMinMax("age")
383+
.options(
384+
FlintSparkIndexOptions(
385+
Map(
386+
"auto_refresh" -> "true",
387+
"scheduler_mode" -> "internal",
388+
"refresh_interval" -> "10 Minute",
389+
"checkpoint_location" -> checkpointDir.getAbsolutePath)),
390+
testFlintIndex)
391+
.create()
392+
393+
val propertiesJson = compact(render(getPropertiesJValue(testFlintIndex)))
394+
propertiesJson should matchJson(s"""
399395
| {
400396
| "metadataCacheVersion": "${FlintMetadataCache.metadataCacheVersion}",
401397
| "refreshInterval": 600,
402398
| "sourceTables": ["$testTable"]
403399
| }
404400
|""".stripMargin)
405401

406-
flint.refreshIndex(testFlintIndex)
407-
compact(render(getPropertiesJValue(testFlintIndex))) should not include "lastRefreshTime"
408-
}
402+
flint.refreshIndex(testFlintIndex)
403+
compact(render(getPropertiesJValue(testFlintIndex))) should not include "lastRefreshTime"
409404
}
410405
}
411406

0 commit comments

Comments
 (0)