Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding PPL GET Api endpoint #2464

Closed
wants to merge 11 commits into from
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to understand why there are a lot of these mini classes that just change the method. My understanding is it's trying to subtly change the extended test with a new method, but I'm not sure I follow why this is better than adding more tests to the base test class that use different methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just the easiest way in java to separate different aspects of the test into different classes - each class is responsible for one thing - the "single responsibility" principle

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add GET api test in each IT? E.g. DedupCommandIT is focus on IntegrationTest instead of dedup command test, instead of REST interface.
Add GET API in doc test (endpoint.rst) should be enough?

Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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"));
}
}
Loading
Loading