Skip to content

Commit 4a262d6

Browse files
committed
Migrate case, datetime, condition, cryptographic function ITs
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent ef81a5f commit 4a262d6

12 files changed

Lines changed: 275 additions & 330 deletions

integ-test/src/test/java/org/opensearch/sql/calcite/standalone/CalcitePPLBuiltinFunctionsNullIT.java renamed to integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLBuiltinFunctionsNullIT.java

Lines changed: 129 additions & 139 deletions
Large diffs are not rendered by default.

integ-test/src/test/java/org/opensearch/sql/calcite/standalone/CalcitePPLCaseFunctionIT.java renamed to integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLCaseFunctionIT.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/*
2-
* Copyright OpenSearch Contributors
3-
* SPDX-License-Identifier: Apache-2.0
2+
*
3+
* * Copyright OpenSearch Contributors
4+
* * SPDX-License-Identifier: Apache-2.0
5+
*
46
*/
57

6-
package org.opensearch.sql.calcite.standalone;
8+
package org.opensearch.sql.calcite.remote;
79

810
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_WEBLOGS;
911
import static org.opensearch.sql.util.MatcherUtils.rows;
@@ -15,6 +17,7 @@
1517
import org.json.JSONObject;
1618
import org.junit.jupiter.api.Test;
1719
import org.opensearch.client.Request;
20+
import org.opensearch.sql.calcite.standalone.CalcitePPLIntegTestCase;
1821
import org.opensearch.sql.legacy.TestsConstants;
1922

2023
public class CalcitePPLCaseFunctionIT extends CalcitePPLIntegTestCase {

integ-test/src/test/java/org/opensearch/sql/calcite/standalone/CalcitePPLCastFunctionIT.java renamed to integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLCastFunctionIT.java

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
/*
2-
* Copyright OpenSearch Contributors
3-
* SPDX-License-Identifier: Apache-2.0
2+
*
3+
* * Copyright OpenSearch Contributors
4+
* * SPDX-License-Identifier: Apache-2.0
5+
*
46
*/
57

6-
package org.opensearch.sql.calcite.standalone;
8+
package org.opensearch.sql.calcite.remote;
79

810
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DATATYPE_NONNUMERIC;
911
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DATATYPE_NUMERIC;
1012
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_STATE_COUNTRY;
1113
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_STATE_COUNTRY_WITH_NULL;
14+
import static org.opensearch.sql.util.MatcherUtils.assertJsonEquals;
1215
import static org.opensearch.sql.util.MatcherUtils.rows;
1316
import static org.opensearch.sql.util.MatcherUtils.schema;
1417
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
@@ -18,19 +21,23 @@
1821
import org.json.JSONObject;
1922
import org.junit.Test;
2023
import org.opensearch.sql.common.antlr.SyntaxCheckException;
24+
import org.opensearch.sql.ppl.PPLIntegTestCase;
2125

22-
public class CalcitePPLCastFunctionIT extends CalcitePPLIntegTestCase {
26+
public class CalcitePPLCastFunctionIT extends PPLIntegTestCase {
2327
@Override
24-
public void init() throws IOException {
28+
public void init() throws Exception {
2529
super.init();
30+
enableCalcite();
31+
disallowCalciteFallback();
32+
2633
loadIndex(Index.STATE_COUNTRY);
2734
loadIndex(Index.STATE_COUNTRY_WITH_NULL);
2835
loadIndex(Index.DATA_TYPE_NUMERIC);
2936
loadIndex(Index.DATA_TYPE_NONNUMERIC);
3037
}
3138

3239
@Test
33-
public void testCast() {
40+
public void testCast() throws IOException {
3441
JSONObject actual =
3542
executeQuery(
3643
String.format(
@@ -42,7 +49,7 @@ public void testCast() {
4249
}
4350

4451
@Test
45-
public void testCastOverriding() {
52+
public void testCastOverriding() throws IOException {
4653
JSONObject actual =
4754
executeQuery(
4855
String.format(
@@ -56,7 +63,7 @@ public void testCastOverriding() {
5663

5764
@Test
5865
public void testCastToUnknownType() {
59-
assertThrows(
66+
assertThrowsWithReplace(
6067
SyntaxCheckException.class,
6168
() ->
6269
executeQuery(
@@ -66,7 +73,7 @@ public void testCastToUnknownType() {
6673
}
6774

6875
@Test
69-
public void testChainedCast() {
76+
public void testChainedCast() throws IOException {
7077
JSONObject actual =
7178
executeQuery(
7279
String.format(
@@ -80,14 +87,14 @@ public void testChainedCast() {
8087
}
8188

8289
@Test
83-
public void testCastNullValues() {
84-
String actual =
85-
execute(
90+
public void testCastNullValues() throws IOException {
91+
JSONObject actual =
92+
executeQuery(
8693
String.format(
8794
"source=%s | eval a = cast(state as string) | fields a",
8895
TEST_INDEX_STATE_COUNTRY_WITH_NULL));
8996

90-
assertEquals(
97+
assertJsonEquals(
9198
"{\n"
9299
+ " \"schema\": [\n"
93100
+ " {\n"
@@ -118,17 +125,17 @@ public void testCastNullValues() {
118125
+ " \"total\": 6,\n"
119126
+ " \"size\": 6\n"
120127
+ "}",
121-
actual);
128+
actual.toString());
122129
}
123130

124131
@Test
125-
public void testCastToUnsupportedType() {
126-
String actual =
127-
execute(
132+
public void testCastToUnsupportedType() throws IOException {
133+
JSONObject actual =
134+
executeQuery(
128135
String.format(
129136
"source=%s | eval a = cast(name as boolean) | fields a", TEST_INDEX_STATE_COUNTRY));
130137

131-
assertEquals(
138+
assertJsonEquals(
132139
"{\n"
133140
+ " \"schema\": [\n"
134141
+ " {\n"
@@ -153,11 +160,11 @@ public void testCastToUnsupportedType() {
153160
+ " \"total\": 4,\n"
154161
+ " \"size\": 4\n"
155162
+ "}",
156-
actual);
163+
actual.toString());
157164
}
158165

159166
@Test
160-
public void testCastLiteralToBoolean() {
167+
public void testCastLiteralToBoolean() throws IOException {
161168
// In OpenSearch V2:
162169
// POST /_plugins/_ppl
163170
// {
@@ -210,12 +217,12 @@ public void testCastLiteralToBoolean() {
210217
TEST_INDEX_DATATYPE_NUMERIC));
211218
verifyDataRows(actual, rows(true));
212219

213-
String actualString =
214-
execute(
220+
actual =
221+
executeQuery(
215222
String.format(
216223
"source=%s | eval a = cast('2' as boolean) | fields a | head 1",
217224
TEST_INDEX_DATATYPE_NUMERIC));
218-
assertEquals(
225+
assertJsonEquals(
219226
""
220227
+ "{\n"
221228
+ " \"schema\": [\n"
@@ -232,7 +239,7 @@ public void testCastLiteralToBoolean() {
232239
+ " \"total\": 1,\n"
233240
+ " \"size\": 1\n"
234241
+ "}",
235-
actualString);
242+
actual.toString());
236243

237244
actual =
238245
executeQuery(
@@ -241,12 +248,12 @@ public void testCastLiteralToBoolean() {
241248
TEST_INDEX_DATATYPE_NUMERIC));
242249
verifyDataRows(actual, rows(false));
243250

244-
actualString =
245-
execute(
251+
actual =
252+
executeQuery(
246253
String.format(
247254
"source=%s | eval a = cast('aa' as boolean) | fields a | head 1",
248255
TEST_INDEX_DATATYPE_NUMERIC));
249-
assertEquals(
256+
assertJsonEquals(
250257
""
251258
+ "{\n"
252259
+ " \"schema\": [\n"
@@ -263,11 +270,11 @@ public void testCastLiteralToBoolean() {
263270
+ " \"total\": 1,\n"
264271
+ " \"size\": 1\n"
265272
+ "}",
266-
actualString);
273+
actual.toString());
267274
}
268275

269276
@Test
270-
public void testCastINT() {
277+
public void testCastINT() throws IOException {
271278
JSONObject actual =
272279
executeQuery(
273280
String.format(
@@ -305,7 +312,7 @@ public void testCastINT() {
305312
}
306313

307314
@Test
308-
public void testCastLONG() {
315+
public void testCastLONG() throws IOException {
309316
JSONObject actual =
310317
executeQuery(
311318
String.format(
@@ -336,7 +343,7 @@ public void testCastLONG() {
336343
}
337344

338345
@Test
339-
public void testCastFLOAT() {
346+
public void testCastFLOAT() throws IOException {
340347
JSONObject actual =
341348
executeQuery(
342349
String.format(
@@ -367,7 +374,7 @@ public void testCastFLOAT() {
367374
}
368375

369376
@Test
370-
public void testCastDOUBLE() {
377+
public void testCastDOUBLE() throws IOException {
371378
JSONObject actual =
372379
executeQuery(
373380
String.format(
@@ -398,7 +405,7 @@ public void testCastDOUBLE() {
398405
}
399406

400407
@Test
401-
public void testCastBOOLEAN() {
408+
public void testCastBOOLEAN() throws IOException {
402409
JSONObject actual;
403410
actual =
404411
executeQuery(
@@ -444,7 +451,7 @@ public void testCastBOOLEAN() {
444451
}
445452

446453
@Test
447-
public void testCastNumericSTRING() {
454+
public void testCastNumericSTRING() throws IOException {
448455
JSONObject actual =
449456
executeQuery(
450457
String.format(

integ-test/src/test/java/org/opensearch/sql/calcite/standalone/CalcitePPLCryptographicFunctionIT.java renamed to integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLCryptographicFunctionIT.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/*
2-
* Copyright OpenSearch Contributors
3-
* SPDX-License-Identifier: Apache-2.0
2+
*
3+
* * Copyright OpenSearch Contributors
4+
* * SPDX-License-Identifier: Apache-2.0
5+
*
46
*/
57

6-
package org.opensearch.sql.calcite.standalone;
8+
package org.opensearch.sql.calcite.remote;
79

810
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_STATE_COUNTRY;
911
import static org.opensearch.sql.util.MatcherUtils.rows;
@@ -15,16 +17,20 @@
1517
import java.io.IOException;
1618
import org.json.JSONObject;
1719
import org.junit.jupiter.api.Test;
20+
import org.opensearch.sql.ppl.PPLIntegTestCase;
1821

19-
public class CalcitePPLCryptographicFunctionIT extends CalcitePPLIntegTestCase {
22+
public class CalcitePPLCryptographicFunctionIT extends PPLIntegTestCase {
2023
@Override
21-
public void init() throws IOException {
24+
public void init() throws Exception {
2225
super.init();
26+
enableCalcite();
27+
disallowCalciteFallback();
28+
2329
loadIndex(Index.STATE_COUNTRY);
2430
}
2531

2632
@Test
27-
public void testMd5() {
33+
public void testMd5() throws IOException {
2834
JSONObject actual =
2935
executeQuery(
3036
String.format(
@@ -37,7 +43,7 @@ public void testMd5() {
3743
}
3844

3945
@Test
40-
public void testSha1() {
46+
public void testSha1() throws IOException {
4147
JSONObject actual =
4248
executeQuery(
4349
String.format(
@@ -53,7 +59,7 @@ public void testSha1() {
5359
}
5460

5561
@Test
56-
public void testSha2() {
62+
public void testSha2() throws IOException {
5763
JSONObject actual =
5864
executeQuery(
5965
String.format(
@@ -79,7 +85,7 @@ public void testSha2() {
7985
@Test
8086
public void testSha2WrongAlgorithmShouldThrow() {
8187
Throwable e =
82-
assertThrows(
88+
assertThrowsWithReplace(
8389
IllegalArgumentException.class,
8490
() ->
8591
executeQuery(

0 commit comments

Comments
 (0)