From 7b2fa89d14a5b9ae4226d1bd589558d9da14e409 Mon Sep 17 00:00:00 2001 From: YANGDB Date: Mon, 1 Jan 2024 21:21:41 -0800 Subject: [PATCH] fix spotlessApply issues Signed-off-by: YANGDB --- .../sql/ppl/ConvertTZFunctionWithGetIT.java | 19 +++++++++++ .../opensearch/sql/ppl/DataTypeWithGetIT.java | 18 +++++++++++ .../sql/ppl/DateTimeComparisonWithGetIT.java | 22 +++++++++++++ .../sql/ppl/DateTimeFunctionWithGetIT.java | 18 +++++++++++ .../ppl/DateTimeImplementationWithGetIT.java | 18 +++++++++++ .../sql/ppl/DedupCommandWithGetIT.java | 18 +++++++++++ .../sql/ppl/DescribeCommandWithGetIT.java | 18 +++++++++++ .../opensearch/sql/ppl/ExplainWithGetIT.java | 18 +++++++++++ .../sql/ppl/FieldsCommandWithGetIT.java | 18 +++++++++++ .../sql/ppl/HeadCommandWithGetIT.java | 18 +++++++++++ .../InformationSchemaCommandWithGetIT.java | 18 +++++++++++ .../ppl/LegacyAPICompatibilityWithGetIT.java | 18 +++++++++++ .../sql/ppl/LikeQueryWithGetIT.java | 18 +++++++++++ .../sql/ppl/MatchBoolPrefixWithGetIT.java | 18 +++++++++++ .../sql/ppl/MatchPhrasePrefixWithGetIT.java | 18 +++++++++++ .../sql/ppl/MatchPhraseWithGetIT.java | 18 +++++++++++ .../opensearch/sql/ppl/MatchWithGetIT.java | 18 +++++++++++ .../ppl/MathematicalFunctionWithGetIT.java | 18 +++++++++++ .../opensearch/sql/ppl/MetricsWithGetIT.java | 17 ++++++++++ .../sql/ppl/MultiMatchWithGetIT.java | 31 ++++++++++++++++++ .../sql/ppl/NowLikeFunctionWithGetIT.java | 32 +++++++++++++++++++ .../sql/ppl/ObjectFieldOperateWithGetIT.java | 18 +++++++++++ .../opensearch/sql/ppl/OperatorWithGetIT.java | 18 +++++++++++ .../opensearch/sql/ppl/PPLIntegTestCase.java | 23 +++++++++++++ .../sql/ppl/ParseCommandWithGetIT.java | 18 +++++++++++ .../sql/ppl/PositionFunctionWithGetIT.java | 18 +++++++++++ ...PrometheusDataSourceCommandsWithGetIT.java | 18 +++++++++++ .../sql/ppl/QueryAnalysisWithGetIT.java | 18 +++++++++++ .../sql/ppl/QueryStringWithGetIT.java | 18 +++++++++++ .../sql/ppl/RareCommandWithGetIT.java | 18 +++++++++++ .../sql/ppl/RelevanceFunctionWithGetIT.java | 18 +++++++++++ .../sql/ppl/RenameCommandWithGetIT.java | 18 +++++++++++ .../sql/ppl/ResourceMonitorWithGetIT.java | 18 +++++++++++ .../sql/ppl/SearchCommandWithGetIT.java | 18 +++++++++++ .../opensearch/sql/ppl/SettingsWithGetIT.java | 18 +++++++++++ .../ppl/ShowDataSourcesCommandWithGetIT.java | 18 +++++++++++ .../sql/ppl/SimpleQueryStringWithGetIT.java | 18 +++++++++++ .../sql/ppl/SortCommandWithGetIT.java | 18 +++++++++++ .../sql/ppl/StatsCommandWithGetIT.java | 18 +++++++++++ .../sql/ppl/SystemFunctionWithGetIT.java | 18 +++++++++++ .../sql/ppl/TextFunctionWithGetIT.java | 19 +++++++++++ .../sql/ppl/TopCommandWithGetIT.java | 20 ++++++++++++ .../sql/ppl/WhereCommandWithGetIT.java | 20 ++++++++++++ .../request/PPLQueryRequestFactory.java | 3 +- .../sql/plugin/rest/RestPPLQueryAction.java | 8 ++++- spark/src/main/antlr/SqlBaseLexer.g4 | 2 ++ spark/src/main/antlr/SqlBaseParser.g4 | 30 +++++++++++++++-- 47 files changed, 852 insertions(+), 6 deletions(-) create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/ConvertTZFunctionWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/DataTypeWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeComparisonWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeFunctionWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeImplementationWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/DedupCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/DescribeCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/ExplainWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/FieldsCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/HeadCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/InformationSchemaCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/LegacyAPICompatibilityWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/LikeQueryWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/MatchBoolPrefixWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/MatchPhrasePrefixWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/MatchPhraseWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/MatchWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/MathematicalFunctionWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/MetricsWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/MultiMatchWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/NowLikeFunctionWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/ObjectFieldOperateWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/OperatorWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/ParseCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/PositionFunctionWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/PrometheusDataSourceCommandsWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/QueryAnalysisWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/QueryStringWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/RareCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/RelevanceFunctionWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/RenameCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/ResourceMonitorWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/SearchCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/SettingsWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/ShowDataSourcesCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/SimpleQueryStringWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/SortCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/StatsCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/SystemFunctionWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/TextFunctionWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/TopCommandWithGetIT.java create mode 100644 integ-test/src/test/java/org/opensearch/sql/ppl/WhereCommandWithGetIT.java diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/ConvertTZFunctionWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/ConvertTZFunctionWithGetIT.java new file mode 100644 index 0000000000..9ebda09294 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/ConvertTZFunctionWithGetIT.java @@ -0,0 +1,19 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import static org.opensearch.rest.RestRequest.Method.GET; + +import java.io.IOException; + +/** Run ConvertTZFunctionIT tests using http GET request */ +public class ConvertTZFunctionWithGetIT extends ConvertTZFunctionIT { + @Override + public void init() throws IOException { + super.init(); + this.method = GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/DataTypeWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/DataTypeWithGetIT.java new file mode 100644 index 0000000000..3cdfe5f869 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/DataTypeWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run DataTypeIT tests using http GET request */ +public class DataTypeWithGetIT extends DataTypeIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeComparisonWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeComparisonWithGetIT.java new file mode 100644 index 0000000000..e027dccf2b --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeComparisonWithGetIT.java @@ -0,0 +1,22 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run DateTimeComparisonIT tests using http GET request */ +public class DateTimeComparisonWithGetIT extends DateTimeComparisonIT { + public DateTimeComparisonWithGetIT(String functionCall, String name, Boolean expectedResult) { + super(functionCall, name, expectedResult); + } + + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeFunctionWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeFunctionWithGetIT.java new file mode 100644 index 0000000000..e9cef00d15 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeFunctionWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run DateTimeFunctionIT tests using http GET request */ +public class DateTimeFunctionWithGetIT extends DateTimeFunctionIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeImplementationWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeImplementationWithGetIT.java new file mode 100644 index 0000000000..c40856d221 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeImplementationWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run DateTimeImplementationIT tests using http GET request */ +public class DateTimeImplementationWithGetIT extends DateTimeImplementationIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/DedupCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/DedupCommandWithGetIT.java new file mode 100644 index 0000000000..8092dd716f --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/DedupCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run DedupCommandIT tests using http GET request */ +public class DedupCommandWithGetIT extends DedupCommandIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/DescribeCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/DescribeCommandWithGetIT.java new file mode 100644 index 0000000000..33e2672663 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/DescribeCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run DescribeCommandIT tests using http GET request */ +public class DescribeCommandWithGetIT extends DescribeCommandIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/ExplainWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/ExplainWithGetIT.java new file mode 100644 index 0000000000..77cfdb9e55 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/ExplainWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run ExplainIT tests using http GET request */ +public class ExplainWithGetIT extends ExplainIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/FieldsCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/FieldsCommandWithGetIT.java new file mode 100644 index 0000000000..01e47110e7 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/FieldsCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run FieldsCommandIT tests using http GET request */ +public class FieldsCommandWithGetIT extends FieldsCommandIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/HeadCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/HeadCommandWithGetIT.java new file mode 100644 index 0000000000..87dd114aec --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/HeadCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run HeadCommandIT tests using http GET request */ +public class HeadCommandWithGetIT extends HeadCommandIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/InformationSchemaCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/InformationSchemaCommandWithGetIT.java new file mode 100644 index 0000000000..0a83893e3f --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/InformationSchemaCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run InformationSchemaCommandIT tests using http GET request */ +public class InformationSchemaCommandWithGetIT extends InformationSchemaCommandIT { + @Override + protected void init() throws InterruptedException, IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/LegacyAPICompatibilityWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/LegacyAPICompatibilityWithGetIT.java new file mode 100644 index 0000000000..7cbf9965f7 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/LegacyAPICompatibilityWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run LegacyAPICompatibilityIT tests using http GET request */ +public class LegacyAPICompatibilityWithGetIT extends LegacyAPICompatibilityIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/LikeQueryWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/LikeQueryWithGetIT.java new file mode 100644 index 0000000000..65845ae52d --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/LikeQueryWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run LikeQueryIT tests using http GET request */ +public class LikeQueryWithGetIT extends LikeQueryIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/MatchBoolPrefixWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/MatchBoolPrefixWithGetIT.java new file mode 100644 index 0000000000..9190b61dca --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/MatchBoolPrefixWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run MatchBoolPrefixIT tests using http GET request */ +public class MatchBoolPrefixWithGetIT extends MatchBoolPrefixIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/MatchPhrasePrefixWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/MatchPhrasePrefixWithGetIT.java new file mode 100644 index 0000000000..3d0c513dc3 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/MatchPhrasePrefixWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run MatchPhrasePrefixIT tests using http GET request */ +public class MatchPhrasePrefixWithGetIT extends MatchPhrasePrefixIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/MatchPhraseWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/MatchPhraseWithGetIT.java new file mode 100644 index 0000000000..0902444321 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/MatchPhraseWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run MatchPhraseIT tests using http GET request */ +public class MatchPhraseWithGetIT extends MatchPhraseIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/MatchWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/MatchWithGetIT.java new file mode 100644 index 0000000000..6d06e3ce0b --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/MatchWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run MatchIT tests using http GET request */ +public class MatchWithGetIT extends MatchIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/MathematicalFunctionWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/MathematicalFunctionWithGetIT.java new file mode 100644 index 0000000000..d333d679d0 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/MathematicalFunctionWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run MathematicalFunctionIT tests using http GET request */ +public class MathematicalFunctionWithGetIT extends MathematicalFunctionIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/MetricsWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/MetricsWithGetIT.java new file mode 100644 index 0000000000..777d976d2b --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/MetricsWithGetIT.java @@ -0,0 +1,17 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import org.opensearch.rest.RestRequest; + +/** Run MetricsIT tests using http GET request */ +public class MetricsWithGetIT extends MetricsIT { + @Override + public void init() throws Exception { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/MultiMatchWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/MultiMatchWithGetIT.java new file mode 100644 index 0000000000..0e7866ef11 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/MultiMatchWithGetIT.java @@ -0,0 +1,31 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BEER; + +import java.io.IOException; +import org.junit.Test; +import org.opensearch.rest.RestRequest; + +/** Run MultiMatchIT tests using http GET request */ +public class MultiMatchWithGetIT extends MultiMatchIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } + + @Test + public void test_multi_match() throws IOException { + String query = + "SOURCE=" + + TEST_INDEX_BEER + + " | WHERE multi_match(['Tags' ^ 1.5, Title, 'Body' 4.2], 'taste') | fields Id"; + var result = executeQuery(query); + assertEquals(16, result.getInt("total")); + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/NowLikeFunctionWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/NowLikeFunctionWithGetIT.java new file mode 100644 index 0000000000..a949ab8cc0 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/NowLikeFunctionWithGetIT.java @@ -0,0 +1,32 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.util.function.BiFunction; +import java.util.function.Supplier; +import org.opensearch.rest.RestRequest; + +/** Run NowLikeFunctionIT tests using http GET request */ +public class NowLikeFunctionWithGetIT extends NowLikeFunctionIT { + public NowLikeFunctionWithGetIT( + String name, + Boolean hasFsp, + Boolean hasShortcut, + Boolean constValue, + Supplier referenceGetter, + BiFunction parser, + String serializationPatternStr) { + super(name, hasFsp, hasShortcut, constValue, referenceGetter, parser, serializationPatternStr); + } + + @Override + public void init() throws Exception { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/ObjectFieldOperateWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/ObjectFieldOperateWithGetIT.java new file mode 100644 index 0000000000..da1501a4ec --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/ObjectFieldOperateWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run ObjectFieldOperateIT tests using http GET request */ +public class ObjectFieldOperateWithGetIT extends ObjectFieldOperateIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/OperatorWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/OperatorWithGetIT.java new file mode 100644 index 0000000000..a4f98f771f --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/OperatorWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run OperatorIT tests using http GET request */ +public class OperatorWithGetIT extends OperatorIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/PPLIntegTestCase.java b/integ-test/src/test/java/org/opensearch/sql/ppl/PPLIntegTestCase.java index 459788021d..f13106a8c3 100644 --- a/integ-test/src/test/java/org/opensearch/sql/ppl/PPLIntegTestCase.java +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/PPLIntegTestCase.java @@ -6,6 +6,7 @@ package org.opensearch.sql.ppl; import static org.opensearch.sql.legacy.TestUtils.getResponseBody; +import static org.opensearch.sql.plugin.request.PPLQueryRequestFactory.PPL_URL_PARAM_KEY; import static org.opensearch.sql.plugin.rest.RestPPLQueryAction.EXPLAIN_API_ENDPOINT; import static org.opensearch.sql.plugin.rest.RestPPLQueryAction.QUERY_API_ENDPOINT; @@ -17,10 +18,12 @@ import org.opensearch.client.Request; import org.opensearch.client.RequestOptions; import org.opensearch.client.Response; +import org.opensearch.rest.RestRequest; import org.opensearch.sql.legacy.SQLIntegTestCase; /** OpenSearch Rest integration test base for PPL testing. */ public abstract class PPLIntegTestCase extends SQLIntegTestCase { + protected RestRequest.Method method = RestRequest.Method.POST; protected JSONObject executeQuery(String query) throws IOException { return jsonify(executeQueryToString(query)); @@ -53,6 +56,16 @@ protected String executeCsvQuery(String query) throws IOException { } protected Request buildRequest(String query, String endpoint) { + switch (method) { + case GET: + return buildGETRequest(query, endpoint); + case POST: + default: + return buildPOSTRequest(query, endpoint); + } + } + + private Request buildPOSTRequest(String query, String endpoint) { Request request = new Request("POST", endpoint); request.setJsonEntity(String.format(Locale.ROOT, "{\n" + " \"query\": \"%s\"\n" + "}", query)); @@ -62,6 +75,16 @@ protected Request buildRequest(String query, String endpoint) { return request; } + private Request buildGETRequest(String query, String endpoint) { + Request request = new Request("GET", endpoint); + request.addParameter(PPL_URL_PARAM_KEY, query); + + RequestOptions.Builder restOptionsBuilder = RequestOptions.DEFAULT.toBuilder(); + restOptionsBuilder.addHeader("Content-Type", "application/json"); + request.setOptions(restOptionsBuilder); + return request; + } + protected static JSONObject updateClusterSettings(ClusterSetting setting) throws IOException { Request request = new Request("PUT", "/_cluster/settings"); String persistentSetting = diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/ParseCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/ParseCommandWithGetIT.java new file mode 100644 index 0000000000..5627f464c6 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/ParseCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run ParseCommandIT tests using http GET request */ +public class ParseCommandWithGetIT extends ParseCommandIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/PositionFunctionWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/PositionFunctionWithGetIT.java new file mode 100644 index 0000000000..83c4cd4053 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/PositionFunctionWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run PositionFunctionIT tests using http GET request */ +public class PositionFunctionWithGetIT extends PositionFunctionIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/PrometheusDataSourceCommandsWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/PrometheusDataSourceCommandsWithGetIT.java new file mode 100644 index 0000000000..04f1e5018b --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/PrometheusDataSourceCommandsWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run PrometheusDataSourceCommandsIT tests using http GET request */ +public class PrometheusDataSourceCommandsWithGetIT extends PrometheusDataSourceCommandsIT { + @Override + protected void init() throws InterruptedException, IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/QueryAnalysisWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/QueryAnalysisWithGetIT.java new file mode 100644 index 0000000000..e885d98a0c --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/QueryAnalysisWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run QueryAnalysisIT tests using http GET request */ +public class QueryAnalysisWithGetIT extends QueryAnalysisIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/QueryStringWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/QueryStringWithGetIT.java new file mode 100644 index 0000000000..9fcca7fc32 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/QueryStringWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run QueryStringIT tests using http GET request */ +public class QueryStringWithGetIT extends QueryStringIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/RareCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/RareCommandWithGetIT.java new file mode 100644 index 0000000000..0939c323d0 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/RareCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run RareCommandIT tests using http GET request */ +public class RareCommandWithGetIT extends RareCommandIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/RelevanceFunctionWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/RelevanceFunctionWithGetIT.java new file mode 100644 index 0000000000..9b2a098806 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/RelevanceFunctionWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run RelevanceFunctionIT tests using http GET request */ +public class RelevanceFunctionWithGetIT extends RelevanceFunctionIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/RenameCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/RenameCommandWithGetIT.java new file mode 100644 index 0000000000..7a921152c0 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/RenameCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run ConvertTZFunctionIT tests using http GET request */ +public class RenameCommandWithGetIT extends RenameCommandIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/ResourceMonitorWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/ResourceMonitorWithGetIT.java new file mode 100644 index 0000000000..5d936c44f8 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/ResourceMonitorWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run ResourceMonitorIT tests using http GET request */ +public class ResourceMonitorWithGetIT extends ResourceMonitorIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/SearchCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/SearchCommandWithGetIT.java new file mode 100644 index 0000000000..34ab43dfa7 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/SearchCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run SearchCommandIT tests using http GET request */ +public class SearchCommandWithGetIT extends SearchCommandIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/SettingsWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/SettingsWithGetIT.java new file mode 100644 index 0000000000..d20bd3715e --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/SettingsWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run SettingsIT tests using http GET request */ +public class SettingsWithGetIT extends SettingsIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/ShowDataSourcesCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/ShowDataSourcesCommandWithGetIT.java new file mode 100644 index 0000000000..f63c38db36 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/ShowDataSourcesCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run ShowDataSourcesCommandIT tests using http GET request */ +public class ShowDataSourcesCommandWithGetIT extends ShowDataSourcesCommandIT { + @Override + protected void init() throws InterruptedException, IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/SimpleQueryStringWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/SimpleQueryStringWithGetIT.java new file mode 100644 index 0000000000..7ac74983e4 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/SimpleQueryStringWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run SimpleQueryStringIT tests using http GET request */ +public class SimpleQueryStringWithGetIT extends SimpleQueryStringIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/SortCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/SortCommandWithGetIT.java new file mode 100644 index 0000000000..6f5453360f --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/SortCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run SortCommandIT tests using http GET request */ +public class SortCommandWithGetIT extends SortCommandIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/StatsCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/StatsCommandWithGetIT.java new file mode 100644 index 0000000000..79c6347ca1 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/StatsCommandWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run StatsCommandIT tests using http GET request */ +public class StatsCommandWithGetIT extends StatsCommandIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/SystemFunctionWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/SystemFunctionWithGetIT.java new file mode 100644 index 0000000000..8f56fcd886 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/SystemFunctionWithGetIT.java @@ -0,0 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import java.io.IOException; +import org.opensearch.rest.RestRequest; + +/** Run SystemFunctionIT tests using http GET request */ +public class SystemFunctionWithGetIT extends SystemFunctionIT { + @Override + public void init() throws IOException { + super.init(); + this.method = RestRequest.Method.GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/TextFunctionWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/TextFunctionWithGetIT.java new file mode 100644 index 0000000000..50d5b341c1 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/TextFunctionWithGetIT.java @@ -0,0 +1,19 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import static org.opensearch.rest.RestRequest.Method.GET; + +import java.io.IOException; + +/** Run TextFunctionIT tests using http GET request */ +public class TextFunctionWithGetIT extends TextFunctionIT { + @Override + public void init() throws IOException { + super.init(); + this.method = GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/TopCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/TopCommandWithGetIT.java new file mode 100644 index 0000000000..0976f40bcb --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/TopCommandWithGetIT.java @@ -0,0 +1,20 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import static org.opensearch.rest.RestRequest.Method.GET; + +import java.io.IOException; + +/** Run TopCommandIT tests using http GET request */ +public class TopCommandWithGetIT extends TopCommandIT { + + @Override + public void init() throws IOException { + super.init(); + this.method = GET; + } +} diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/WhereCommandWithGetIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/WhereCommandWithGetIT.java new file mode 100644 index 0000000000..8025b161a4 --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/WhereCommandWithGetIT.java @@ -0,0 +1,20 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.ppl; + +import static org.opensearch.rest.RestRequest.Method.GET; + +import java.io.IOException; + +/** Run WhereCommandIT tests using http GET request */ +public class WhereCommandWithGetIT extends WhereCommandIT { + + @Override + public void init() throws IOException { + super.init(); + this.method = GET; + } +} diff --git a/plugin/src/main/java/org/opensearch/sql/plugin/request/PPLQueryRequestFactory.java b/plugin/src/main/java/org/opensearch/sql/plugin/request/PPLQueryRequestFactory.java index ad734bf150..3a4c23044b 100644 --- a/plugin/src/main/java/org/opensearch/sql/plugin/request/PPLQueryRequestFactory.java +++ b/plugin/src/main/java/org/opensearch/sql/plugin/request/PPLQueryRequestFactory.java @@ -16,7 +16,7 @@ /** Factory of {@link PPLQueryRequest}. */ public class PPLQueryRequestFactory { - private static final String PPL_URL_PARAM_KEY = "ppl"; + public static final String PPL_URL_PARAM_KEY = "ppl"; private static final String PPL_FIELD_NAME = "query"; private static final String QUERY_PARAMS_FORMAT = "format"; private static final String QUERY_PARAMS_SANITIZE = "sanitize"; @@ -43,7 +43,6 @@ public static PPLQueryRequest getPPLRequest(RestRequest request) { private static PPLQueryRequest parsePPLRequestFromUrl(RestRequest restRequest) { String ppl; - ppl = restRequest.param(PPL_URL_PARAM_KEY); if (ppl == null) { throw new IllegalArgumentException("Cannot find ppl parameter from the URL"); diff --git a/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestPPLQueryAction.java b/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestPPLQueryAction.java index d35962be91..d7e04b0686 100644 --- a/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestPPLQueryAction.java +++ b/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestPPLQueryAction.java @@ -76,9 +76,15 @@ public List replacedRoutes() { new ReplacedRoute( RestRequest.Method.POST, QUERY_API_ENDPOINT, RestRequest.Method.POST, LEGACY_QUERY_API_ENDPOINT), + new ReplacedRoute( + RestRequest.Method.GET, QUERY_API_ENDPOINT, + RestRequest.Method.GET, LEGACY_QUERY_API_ENDPOINT), new ReplacedRoute( RestRequest.Method.POST, EXPLAIN_API_ENDPOINT, - RestRequest.Method.POST, LEGACY_EXPLAIN_API_ENDPOINT)); + RestRequest.Method.POST, LEGACY_EXPLAIN_API_ENDPOINT), + new ReplacedRoute( + RestRequest.Method.GET, EXPLAIN_API_ENDPOINT, + RestRequest.Method.GET, LEGACY_EXPLAIN_API_ENDPOINT)); } @Override diff --git a/spark/src/main/antlr/SqlBaseLexer.g4 b/spark/src/main/antlr/SqlBaseLexer.g4 index 9b3dcbc6d1..174887def6 100644 --- a/spark/src/main/antlr/SqlBaseLexer.g4 +++ b/spark/src/main/antlr/SqlBaseLexer.g4 @@ -217,6 +217,7 @@ HOURS: 'HOURS'; IDENTIFIER_KW: 'IDENTIFIER'; IF: 'IF'; IGNORE: 'IGNORE'; +IMMEDIATE: 'IMMEDIATE'; IMPORT: 'IMPORT'; IN: 'IN'; INCLUDE: 'INCLUDE'; @@ -381,6 +382,7 @@ TIMESTAMPADD: 'TIMESTAMPADD'; TIMESTAMPDIFF: 'TIMESTAMPDIFF'; TINYINT: 'TINYINT'; TO: 'TO'; +EXECUTE: 'EXECUTE'; TOUCH: 'TOUCH'; TRAILING: 'TRAILING'; TRANSACTION: 'TRANSACTION'; diff --git a/spark/src/main/antlr/SqlBaseParser.g4 b/spark/src/main/antlr/SqlBaseParser.g4 index 439a12c301..737d5196e7 100644 --- a/spark/src/main/antlr/SqlBaseParser.g4 +++ b/spark/src/main/antlr/SqlBaseParser.g4 @@ -72,6 +72,7 @@ singleTableSchema statement : query #statementDefault + | executeImmediate #visitExecuteImmediate | ctes? dmlStatementNoWith #dmlStatement | USE identifierReference #use | USE namespace identifierReference #useNamespace @@ -230,6 +231,28 @@ statement | unsupportedHiveNativeCommands .*? #failNativeCommand ; +executeImmediate + : EXECUTE IMMEDIATE queryParam=executeImmediateQueryParam (INTO targetVariable=multipartIdentifierList)? executeImmediateUsing? + ; + +executeImmediateUsing + : USING LEFT_PAREN params=namedExpressionSeq RIGHT_PAREN + | USING params=namedExpressionSeq + ; + +executeImmediateQueryParam + : stringLit + | multipartIdentifier + ; + +executeImmediateArgument + : (constant|multipartIdentifier) (AS name=errorCapturingIdentifier)? + ; + +executeImmediateArgumentSeq + : executeImmediateArgument (COMMA executeImmediateArgument)* + ; + timezone : stringLit | LOCAL @@ -979,6 +1002,7 @@ primaryExpression | LEFT_PAREN query RIGHT_PAREN #subqueryExpression | functionName LEFT_PAREN (setQuantifier? argument+=functionArgument (COMMA argument+=functionArgument)*)? RIGHT_PAREN + (WITHIN GROUP LEFT_PAREN ORDER BY sortItem (COMMA sortItem)* RIGHT_PAREN)? (FILTER LEFT_PAREN WHERE where=booleanExpression RIGHT_PAREN)? (nullsOption=(IGNORE | RESPECT) NULLS)? ( OVER windowSpec)? #functionCall | identifier ARROW expression #lambda @@ -994,9 +1018,6 @@ primaryExpression FROM srcStr=valueExpression RIGHT_PAREN #trim | OVERLAY LEFT_PAREN input=valueExpression PLACING replace=valueExpression FROM position=valueExpression (FOR length=valueExpression)? RIGHT_PAREN #overlay - | name=(PERCENTILE_CONT | PERCENTILE_DISC) LEFT_PAREN percentage=valueExpression RIGHT_PAREN - WITHIN GROUP LEFT_PAREN ORDER BY sortItem RIGHT_PAREN - (FILTER LEFT_PAREN WHERE where=booleanExpression RIGHT_PAREN)? ( OVER windowSpec)? #percentile ; literalType @@ -1396,6 +1417,7 @@ ansiNonReserved | IDENTIFIER_KW | IF | IGNORE + | IMMEDIATE | IMPORT | INCLUDE | INDEX @@ -1687,6 +1709,7 @@ nonReserved | ESCAPED | EXCHANGE | EXCLUDE + | EXECUTE | EXISTS | EXPLAIN | EXPORT @@ -1719,6 +1742,7 @@ nonReserved | IDENTIFIER_KW | IF | IGNORE + | IMMEDIATE | IMPORT | IN | INCLUDE