From 6f440129eed00c2806da53961f67158f56cdf0b9 Mon Sep 17 00:00:00 2001 From: Tomoyuki Morita Date: Fri, 6 Sep 2024 11:17:17 -0700 Subject: [PATCH] Fix test failure due to rebase Signed-off-by: Tomoyuki Morita --- .../sql/spark/dispatcher/model/IndexQueryDetails.java | 7 +++++++ .../sql/spark/dispatcher/SparkQueryDispatcherTest.java | 3 ++- .../org/opensearch/sql/spark/utils/SQLQueryUtilsTest.java | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/async-query-core/src/main/java/org/opensearch/sql/spark/dispatcher/model/IndexQueryDetails.java b/async-query-core/src/main/java/org/opensearch/sql/spark/dispatcher/model/IndexQueryDetails.java index 74118cd30a..50ce95ffe0 100644 --- a/async-query-core/src/main/java/org/opensearch/sql/spark/dispatcher/model/IndexQueryDetails.java +++ b/async-query-core/src/main/java/org/opensearch/sql/spark/dispatcher/model/IndexQueryDetails.java @@ -93,6 +93,9 @@ public IndexQueryDetails build() { } public String openSearchIndexName() { + if (getIndexType() == null) { + return null; + } FullyQualifiedTableName fullyQualifiedTableName = getFullyQualifiedTableName(); String indexName = StringUtils.EMPTY; switch (getIndexType()) { @@ -105,6 +108,8 @@ public String openSearchIndexName() { + strip(getIndexName(), STRIP_CHARS) + "_" + getIndexType().getSuffix(); + } else { + return null; } break; case SKIPPING: @@ -114,6 +119,8 @@ public String openSearchIndexName() { case MATERIALIZED_VIEW: if (mvName != null) { // mvName is not available for SHOW MATERIALIZED VIEW query indexName = "flint_" + new FullyQualifiedTableName(mvName).toFlintName(); + } else { + return null; } break; } diff --git a/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/SparkQueryDispatcherTest.java b/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/SparkQueryDispatcherTest.java index 0666756d15..9f12ddf323 100644 --- a/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/SparkQueryDispatcherTest.java +++ b/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/SparkQueryDispatcherTest.java @@ -452,7 +452,8 @@ void testManualRefreshMaterializedViewQuery() { tags.put(JOB_TYPE_TAG_KEY, JobType.BATCH.getText()); String query = "CREATE MATERIALIZED VIEW mv_1 AS select * from logs WITH" + " (auto_refresh = false)"; - String sparkSubmitParameters = constructExpectedSparkSubmitParameterString(query); + String sparkSubmitParameters = + constructExpectedSparkSubmitParameterString(query, null, QUERY_ID); StartJobRequest expected = new StartJobRequest( "TEST_CLUSTER:batch", diff --git a/async-query-core/src/test/java/org/opensearch/sql/spark/utils/SQLQueryUtilsTest.java b/async-query-core/src/test/java/org/opensearch/sql/spark/utils/SQLQueryUtilsTest.java index 0680ba9c10..4608bce74e 100644 --- a/async-query-core/src/test/java/org/opensearch/sql/spark/utils/SQLQueryUtilsTest.java +++ b/async-query-core/src/test/java/org/opensearch/sql/spark/utils/SQLQueryUtilsTest.java @@ -284,7 +284,7 @@ void testShowIndex() { assertNotNull(fullyQualifiedTableName); assertEquals(FlintIndexType.COVERING, indexDetails.getIndexType()); assertEquals(IndexQueryActionType.SHOW, indexDetails.getIndexQueryActionType()); - assertEquals("", indexDetails.openSearchIndexName()); + assertNull(indexDetails.openSearchIndexName()); } @Test @@ -300,7 +300,7 @@ void testShowMaterializedView() { assertNull(fullyQualifiedTableName); assertEquals(FlintIndexType.MATERIALIZED_VIEW, indexDetails.getIndexType()); assertEquals(IndexQueryActionType.SHOW, indexDetails.getIndexQueryActionType()); - assertEquals("", indexDetails.openSearchIndexName()); + assertNull(indexDetails.openSearchIndexName()); } @Test