From 5ed9f0a87c388e44f8072bc96302b81b2623d448 Mon Sep 17 00:00:00 2001 From: Tomoyuki Morita Date: Wed, 17 Jul 2024 11:36:10 -0700 Subject: [PATCH] Fix SparkSubmitParameterModifier issue Signed-off-by: Tomoyuki Morita --- .../sql/spark/parameter/SparkSubmitParametersBuilder.java | 4 +++- .../spark/parameter/SparkSubmitParametersBuilderTest.java | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilder.java b/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilder.java index 01a665a485..3fe7d99373 100644 --- a/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilder.java +++ b/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilder.java @@ -154,7 +154,9 @@ public SparkSubmitParametersBuilder sessionExecution(String sessionId, String da } public SparkSubmitParametersBuilder acceptModifier(SparkSubmitParameterModifier modifier) { - modifier.modifyParameters(this); + if (modifier != null) { + modifier.modifyParameters(this); + } return this; } diff --git a/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilderTest.java b/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilderTest.java index 3f4bea02f2..8947cb61f7 100644 --- a/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilderTest.java +++ b/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkSubmitParametersBuilderTest.java @@ -152,6 +152,11 @@ public void testAcceptModifier() { verify(sparkSubmitParameterModifier).modifyParameters(sparkSubmitParametersBuilder); } + @Test + public void testAcceptNullModifier() { + sparkSubmitParametersBuilder.acceptModifier(null); + } + @Test public void testDataSource() { when(sparkParameterComposerCollection.isComposerRegistered(DataSourceType.S3GLUE))