From 0d2a4aa35e0fad4c24c1b7ddd328de9ffe17505c Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:21:45 -0700 Subject: [PATCH] Optimize scheduler interval conf (#3049) (#3082) --- .../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")); } }