Skip to content

Commit

Permalink
Fix qualified mv name check
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Dai <[email protected]>
  • Loading branch information
dai-chen committed Oct 18, 2023
1 parent 1bfce3b commit 2778d68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ object FlintSparkMaterializedView {
* Flint index name
*/
def getFlintIndexName(mvName: String): String = {
require(mvName.contains("."), "Full table name database.mv is required")
require(
mvName.split("\\.").length >= 3,
"Qualified materialized view name catalog.database.mv is required")

s"flint_${mvName.replace(".", "_")}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ class FlintSparkMaterializedViewSuite extends FlintSuite {
mv.name() shouldBe "flint_spark_catalog_default_mv"
}

test("should fail if not full MV name") {
val mv = FlintSparkMaterializedView("mv", "SELECT 1", Map.empty)
assertThrows[IllegalArgumentException] {
mv.name()
}
test("should fail if get name with unqualified MV name") {
the[IllegalArgumentException] thrownBy
FlintSparkMaterializedView("mv", testQuery, Map.empty).name()

the[IllegalArgumentException] thrownBy
FlintSparkMaterializedView("default.mv", testQuery, Map.empty).name()
}

test("get metadata") {
Expand Down

0 comments on commit 2778d68

Please sign in to comment.