Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract source table names from mv query #854

Merged
merged 8 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use constant for metadata cache version
Signed-off-by: Sean Kao <seankao@amazon.com>
  • Loading branch information
seankao-az committed Oct 31, 2024
commit b286b98709a3ce4358503793a3c52819e438ba61
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ case class FlintMetadataCache(

object FlintMetadataCache {

// TODO: constant for version
val metadataCacheVersion = "1.0"
val mockTableName =
"dataSourceName.default.logGroups(logGroupIdentifier:['arn:aws:logs:us-east-1:123456:test-llt-xa', 'arn:aws:logs:us-east-1:123456:sample-lg-1'])"

Expand All @@ -69,6 +69,10 @@ object FlintMetadataCache {
}

// TODO: get source tables from metadata
FlintMetadataCache("1.0", refreshInterval, Array(mockTableName), lastRefreshTime)
FlintMetadataCache(
metadataCacheVersion,
refreshInterval,
Array(mockTableName),
lastRefreshTime)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FlintMetadataCacheSuite extends AnyFlatSpec with Matchers {
.copy(latestLogEntry = Some(flintMetadataLogEntry))

val metadataCache = FlintMetadataCache(metadata)
metadataCache.metadataCacheVersion shouldBe "1.0"
metadataCache.metadataCacheVersion shouldBe FlintMetadataCache.metadataCacheVersion
metadataCache.refreshInterval.get shouldBe 600
metadataCache.sourceTables shouldBe Array(FlintMetadataCache.mockTableName)
metadataCache.lastRefreshTime.get shouldBe 1234567890123L
Expand Down Expand Up @@ -71,7 +71,7 @@ class FlintMetadataCacheSuite extends AnyFlatSpec with Matchers {
.copy(latestLogEntry = Some(flintMetadataLogEntry.copy(lastRefreshCompleteTime = 0L)))

val metadataCache = FlintMetadataCache(metadata)
metadataCache.metadataCacheVersion shouldBe "1.0"
metadataCache.metadataCacheVersion shouldBe FlintMetadataCache.metadataCacheVersion
metadataCache.refreshInterval shouldBe empty
metadataCache.sourceTables shouldBe Array(FlintMetadataCache.mockTableName)
metadataCache.lastRefreshTime shouldBe empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat
| "refresh_interval": "10 Minutes"
| },
| "properties": {
| "metadataCacheVersion": "1.0",
| "metadataCacheVersion": "${FlintMetadataCache.metadataCacheVersion}",
| "refreshInterval": 600,
| "sourceTables": ["${FlintMetadataCache.mockTableName}"],
| "lastRefreshTime": ${testLastRefreshCompleteTime}
Expand Down Expand Up @@ -129,7 +129,9 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat

val properties = flintIndexMetadataService.getIndexMetadata(testFlintIndex).properties
properties should have size 3
properties should contain allOf (Entry("metadataCacheVersion", "1.0"),
properties should contain allOf (Entry(
"metadataCacheVersion",
FlintMetadataCache.metadataCacheVersion),
Entry("lastRefreshTime", testLastRefreshCompleteTime))
properties
.get("sourceTables")
Expand Down Expand Up @@ -162,7 +164,9 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat

val properties = flintIndexMetadataService.getIndexMetadata(testFlintIndex).properties
properties should have size 4
properties should contain allOf (Entry("metadataCacheVersion", "1.0"),
properties should contain allOf (Entry(
"metadataCacheVersion",
FlintMetadataCache.metadataCacheVersion),
Entry("refreshInterval", 600),
Entry("lastRefreshTime", testLastRefreshCompleteTime))
properties
Expand Down Expand Up @@ -195,7 +199,9 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat

val properties = flintIndexMetadataService.getIndexMetadata(testFlintIndex).properties
properties should have size 3
properties should contain allOf (Entry("metadataCacheVersion", "1.0"),
properties should contain allOf (Entry(
"metadataCacheVersion",
FlintMetadataCache.metadataCacheVersion),
Entry("lastRefreshTime", testLastRefreshCompleteTime))
properties
.get("sourceTables")
Expand All @@ -212,7 +218,8 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat

val properties = flintIndexMetadataService.getIndexMetadata(testFlintIndex).properties
properties should have size 2
properties should contain(Entry("metadataCacheVersion", "1.0"))
properties should contain(
Entry("metadataCacheVersion", FlintMetadataCache.metadataCacheVersion))
properties
.get("sourceTables")
.asInstanceOf[List[String]]
Expand Down Expand Up @@ -246,7 +253,9 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat
flintIndexMetadataService.getIndexMetadata(testFlintIndex).schema should have size 1
var properties = flintIndexMetadataService.getIndexMetadata(testFlintIndex).properties
properties should have size 3
properties should contain allOf (Entry("metadataCacheVersion", "1.0"),
properties should contain allOf (Entry(
"metadataCacheVersion",
FlintMetadataCache.metadataCacheVersion),
Entry("lastRefreshTime", testLastRefreshCompleteTime))
properties
.get("sourceTables")
Expand Down Expand Up @@ -278,7 +287,9 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat
flintIndexMetadataService.getIndexMetadata(testFlintIndex).schema should have size 1
properties = flintIndexMetadataService.getIndexMetadata(testFlintIndex).properties
properties should have size 3
properties should contain allOf (Entry("metadataCacheVersion", "1.0"),
properties should contain allOf (Entry(
"metadataCacheVersion",
FlintMetadataCache.metadataCacheVersion),
Entry("lastRefreshTime", testLastRefreshCompleteTime))
properties
.get("sourceTables")
Expand All @@ -296,7 +307,7 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat
"checkpoint_location" -> "s3a://test/"),
s"""
| {
| "metadataCacheVersion": "1.0",
| "metadataCacheVersion": "${FlintMetadataCache.metadataCacheVersion}",
| "refreshInterval": 600,
| "sourceTables": ["${FlintMetadataCache.mockTableName}"]
| }
Expand All @@ -306,7 +317,7 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat
Map.empty[String, String],
s"""
| {
| "metadataCacheVersion": "1.0",
| "metadataCacheVersion": "${FlintMetadataCache.metadataCacheVersion}",
| "sourceTables": ["${FlintMetadataCache.mockTableName}"]
| }
|""".stripMargin),
Expand All @@ -315,7 +326,7 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat
Map("incremental_refresh" -> "true", "checkpoint_location" -> "s3a://test/"),
s"""
| {
| "metadataCacheVersion": "1.0",
| "metadataCacheVersion": "${FlintMetadataCache.metadataCacheVersion}",
| "sourceTables": ["${FlintMetadataCache.mockTableName}"]
| }
|""".stripMargin)).foreach { case (refreshMode, optionsMap, expectedJson) =>
Expand Down Expand Up @@ -389,7 +400,7 @@ class FlintOpenSearchMetadataCacheWriterITSuite extends FlintSparkSuite with Mat
flintMetadataCacheWriter.serialize(index.get.metadata())) \ "_meta" \ "properties"))
propertiesJson should matchJson(s"""
| {
| "metadataCacheVersion": "1.0",
| "metadataCacheVersion": "${FlintMetadataCache.metadataCacheVersion}",
| "refreshInterval": 600,
| "sourceTables": ["${FlintMetadataCache.mockTableName}"]
| }
Expand Down