From d39d65e08b1e4e168a145a280c7fb634a481e5c3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 18 Oct 2024 21:02:39 +0000 Subject: [PATCH] Optimize scheduler interval conf (#3049) * Optimize scheduler interval conf Signed-off-by: Louis Chu * Update OpenSearchAsyncQuerySchedulerConfigComposer.java Signed-off-by: Louis Chu * Update OpenSearchAsyncQuerySchedulerConfigComposer.java Signed-off-by: Louis Chu --------- Signed-off-by: Louis Chu (cherry picked from commit a87061d9a21a59e71365aae18523e47701b24b5e) Signed-off-by: github-actions[bot] --- .../OpenSearchAsyncQuerySchedulerConfigComposer.java | 9 +++++++-- .../OpenSearchAsyncQuerySchedulerConfigComposerTest.java | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/async-query/src/main/java/org/opensearch/sql/spark/config/OpenSearchAsyncQuerySchedulerConfigComposer.java b/async-query/src/main/java/org/opensearch/sql/spark/config/OpenSearchAsyncQuerySchedulerConfigComposer.java index f791b050a1..28fd4b1b58 100644 --- a/async-query/src/main/java/org/opensearch/sql/spark/config/OpenSearchAsyncQuerySchedulerConfigComposer.java +++ b/async-query/src/main/java/org/opensearch/sql/spark/config/OpenSearchAsyncQuerySchedulerConfigComposer.java @@ -9,6 +9,7 @@ import static org.opensearch.sql.spark.data.constants.SparkConstants.FLINT_JOB_EXTERNAL_SCHEDULER_INTERVAL; import lombok.RequiredArgsConstructor; +import org.opensearch.core.common.Strings; import org.opensearch.sql.common.setting.Settings; import org.opensearch.sql.spark.asyncquery.model.AsyncQueryRequestContext; import org.opensearch.sql.spark.dispatcher.model.DispatchQueryRequest; @@ -30,7 +31,11 @@ public void compose( settings.getSettingValue(Settings.Key.ASYNC_QUERY_EXTERNAL_SCHEDULER_INTERVAL); sparkSubmitParameters.setConfigItem( FLINT_JOB_EXTERNAL_SCHEDULER_ENABLED, String.valueOf(externalSchedulerEnabled)); - sparkSubmitParameters.setConfigItem( - FLINT_JOB_EXTERNAL_SCHEDULER_INTERVAL, externalSchedulerInterval); + if (!Strings.isNullOrEmpty(externalSchedulerInterval)) { + externalSchedulerInterval = + "\"" + externalSchedulerInterval + "\""; // Wrap the value with double quotes + sparkSubmitParameters.setConfigItem( + FLINT_JOB_EXTERNAL_SCHEDULER_INTERVAL, externalSchedulerInterval); + } } } diff --git a/async-query/src/test/java/org/opensearch/sql/spark/config/OpenSearchAsyncQuerySchedulerConfigComposerTest.java b/async-query/src/test/java/org/opensearch/sql/spark/config/OpenSearchAsyncQuerySchedulerConfigComposerTest.java index 1556d4db3f..19ab091e25 100644 --- a/async-query/src/test/java/org/opensearch/sql/spark/config/OpenSearchAsyncQuerySchedulerConfigComposerTest.java +++ b/async-query/src/test/java/org/opensearch/sql/spark/config/OpenSearchAsyncQuerySchedulerConfigComposerTest.java @@ -1,5 +1,6 @@ package org.opensearch.sql.spark.config; +import static org.junit.Assert.assertNull; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -40,7 +41,7 @@ public void testCompose() { verify(sparkSubmitParameters) .setConfigItem("spark.flint.job.externalScheduler.enabled", "true"); verify(sparkSubmitParameters) - .setConfigItem("spark.flint.job.externalScheduler.interval", "10 minutes"); + .setConfigItem("spark.flint.job.externalScheduler.interval", "\"10 minutes\""); } @Test @@ -63,6 +64,6 @@ public void testComposeWithMissingInterval() { composer.compose(sparkSubmitParameters, dispatchQueryRequest, context); - verify(sparkSubmitParameters).setConfigItem("spark.flint.job.externalScheduler.interval", ""); + assertNull(sparkSubmitParameters.getConfigItem("spark.flint.job.externalScheduler.interval")); } }