forked from opensearch-project/opensearch-spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract source table names from mv query (opensearch-project#854)
* add sourceTables to MV index metadata properties Signed-off-by: Sean Kao <seankao@amazon.com> * parse source tables from mv query Signed-off-by: Sean Kao <seankao@amazon.com> * test cases for parse source tables from mv query Signed-off-by: Sean Kao <seankao@amazon.com> * use constant for metadata cache version Signed-off-by: Sean Kao <seankao@amazon.com> * write source tables to metadata cache Signed-off-by: Sean Kao <seankao@amazon.com> * address comment Signed-off-by: Sean Kao <seankao@amazon.com> * generate source tables for old mv without new prop Signed-off-by: Sean Kao <seankao@amazon.com> * syntax fix Signed-off-by: Sean Kao <seankao@amazon.com> --------- Signed-off-by: Sean Kao <seankao@amazon.com>
- Loading branch information
1 parent
3cdc2d9
commit ea1fe54
Showing
11 changed files
with
369 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...k-integration/src/test/scala/org/opensearch/flint/spark/FlintSparkIndexFactorySuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.flint.spark | ||
|
||
import org.opensearch.flint.core.storage.FlintOpenSearchIndexMetadataService | ||
import org.opensearch.flint.spark.mv.FlintSparkMaterializedView | ||
import org.opensearch.flint.spark.mv.FlintSparkMaterializedView.MV_INDEX_TYPE | ||
import org.scalatest.matchers.should.Matchers._ | ||
|
||
import org.apache.spark.FlintSuite | ||
|
||
class FlintSparkIndexFactorySuite extends FlintSuite { | ||
|
||
test("create mv should generate source tables if missing in metadata") { | ||
val testTable = "spark_catalog.default.mv_build_test" | ||
val testMvName = "spark_catalog.default.mv" | ||
val testQuery = s"SELECT * FROM $testTable" | ||
|
||
val content = | ||
s""" { | ||
| "_meta": { | ||
| "kind": "$MV_INDEX_TYPE", | ||
| "indexedColumns": [ | ||
| { | ||
| "columnType": "int", | ||
| "columnName": "age" | ||
| } | ||
| ], | ||
| "name": "$testMvName", | ||
| "source": "$testQuery" | ||
| }, | ||
| "properties": { | ||
| "age": { | ||
| "type": "integer" | ||
| } | ||
| } | ||
| } | ||
|""".stripMargin | ||
|
||
val metadata = FlintOpenSearchIndexMetadataService.deserialize(content) | ||
val index = FlintSparkIndexFactory.create(spark, metadata) | ||
index shouldBe defined | ||
index.get | ||
.asInstanceOf[FlintSparkMaterializedView] | ||
.sourceTables should contain theSameElementsAs Array(testTable) | ||
} | ||
} |
Oops, something went wrong.