-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate source tables for old mv without new prop
Signed-off-by: Sean Kao <[email protected]>
- Loading branch information
1 parent
372ea26
commit 559b393
Showing
6 changed files
with
125 additions
and
51 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
51 changes: 51 additions & 0 deletions
51
...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,51 @@ | ||
/* | ||
* 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 table, MV name and query */ | ||
val testTable = "spark_catalog.default.mv_build_test" | ||
val testMvName = "spark_catalog.default.mv" | ||
val testQuery = s"SELECT * FROM $testTable" | ||
|
||
test("create mv should generate source tables if missing in metadata") { | ||
val content = | ||
s""" { | ||
| "_meta": { | ||
| "kind": "$MV_INDEX_TYPE", | ||
| "indexedColumns": [ | ||
| { | ||
| "columnType": "int", | ||
| "columnName": "age" | ||
| } | ||
| ], | ||
| "name": "$testMvName", | ||
| "source": "SELECT age FROM $testTable" | ||
| }, | ||
| "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) | ||
} | ||
} |
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