Skip to content

Commit 8cce7a8

Browse files
authored
update datetime tests to stay within ae bounds (#5534)
Signed-off-by: Simeon Widdis <sawiddis@amazon.com>
1 parent 90358dc commit 8cce7a8

7 files changed

Lines changed: 77 additions & 53 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/legacy/SQLIntegTestCase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,11 @@ public enum Index {
732732
"_doc",
733733
getDataTypeNonnumericIndexMapping(),
734734
"src/test/resources/datatypes.json"),
735+
DATETIME_SIMPLE(
736+
TestsConstants.TEST_INDEX_DATETIME_SIMPLE,
737+
"_doc",
738+
getDateTimeSimpleIndexMapping(),
739+
"src/test/resources/datetime_simple.json"),
735740
BEER(
736741
TestsConstants.TEST_INDEX_BEER, "beer", null, "src/test/resources/beer.stackexchange.json"),
737742
NULL_MISSING(

integ-test/src/test/java/org/opensearch/sql/legacy/TestUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,11 @@ public static String getDataTypeNonnumericIndexMapping() {
414414
return getMappingFile(mappingFile);
415415
}
416416

417+
public static String getDateTimeSimpleIndexMapping() {
418+
String mappingFile = "datetime_simple_index_mapping.json";
419+
return getMappingFile(mappingFile);
420+
}
421+
417422
public static String getGeopointIndexMapping() {
418423
String mappingFile = "geopoint_index_mapping.json";
419424
return getMappingFile(mappingFile);

integ-test/src/test/java/org/opensearch/sql/legacy/TestsConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public class TestsConstants {
6161
public static final String TEST_INDEX_STRINGS = TEST_INDEX + "_strings";
6262
public static final String TEST_INDEX_DATATYPE_NUMERIC = TEST_INDEX + "_datatypes_numeric";
6363
public static final String TEST_INDEX_DATATYPE_NONNUMERIC = TEST_INDEX + "_datatypes_nonnumeric";
64+
public static final String TEST_INDEX_DATETIME_SIMPLE = TEST_INDEX + "_datetime_simple";
6465
public static final String TEST_INDEX_BEER = TEST_INDEX + "_beer";
6566
public static final String TEST_INDEX_NULL_MISSING = TEST_INDEX + "_null_missing";
6667
public static final String TEST_INDEX_CALCS = TEST_INDEX + "_calcs";

integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeComparisonIT.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import static com.carrotsearch.randomizedtesting.RandomizedTest.$;
99
import static com.carrotsearch.randomizedtesting.RandomizedTest.$$;
10-
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DATATYPE_NONNUMERIC;
10+
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DATETIME_SIMPLE;
1111
import static org.opensearch.sql.util.MatcherUtils.rows;
1212
import static org.opensearch.sql.util.MatcherUtils.schema;
1313
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
@@ -28,7 +28,7 @@ public class DateTimeComparisonIT extends PPLIntegTestCase {
2828
@Override
2929
public void init() throws Exception {
3030
super.init();
31-
loadIndex(Index.DATA_TYPE_NONNUMERIC);
31+
loadIndex(Index.DATETIME_SIMPLE);
3232
}
3333

3434
private final TimeZone testTz = TimeZone.getDefault();
@@ -231,7 +231,7 @@ public static Iterable<Object[]> compareLtTimestampWithOtherTypes() {
231231
$("TIMESTAMP('2020-09-16 10:20:30') < DATE('1961-04-12')", "ts_d_f", false),
232232
$("DATE('2020-09-16') < TIMESTAMP('2020-09-16 00:00:00')", "d_ts_f", false),
233233
$("TIMESTAMP('2020-09-16 10:20:30') < TIME('09:07:00')", "ts_t_t", true),
234-
$("TIME('09:07:00') < TIMESTAMP('3077-12-15 22:15:07')", "t_ts_t", true),
234+
$("TIME('09:07:00') < TIMESTAMP('2242-12-15 22:15:07')", "t_ts_t", true),
235235
$("TIMESTAMP('" + today + " 10:20:30') < TIME('10:20:30')", "ts_t_f", false),
236236
$("TIME('20:50:40') < TIMESTAMP('" + today + " 10:20:30')", "t_ts_f", false)));
237237
}
@@ -240,13 +240,13 @@ public static Iterable<Object[]> compareLtTimestampWithOtherTypes() {
240240
public static Iterable<Object[]> compareLtDateWithOtherTypes() {
241241
return Arrays.asList(
242242
$$(
243-
$("DATE('2020-09-16') < TIMESTAMP('3077-04-12 09:07:00')", "d_ts_t", true),
243+
$("DATE('2020-09-16') < TIMESTAMP('2242-04-12 09:07:00')", "d_ts_t", true),
244244
$("TIMESTAMP('1961-04-12 09:07:00') < DATE('1984-12-15')", "ts_d_t", true),
245245
$("DATE('2020-09-16') < TIMESTAMP('2020-09-16 00:00:00')", "d_ts_f", false),
246246
$("TIMESTAMP('2077-04-12 09:07:00') < DATE('2020-09-16')", "ts_d_f", false),
247247
$("DATE('2020-09-16') < TIME('09:07:00')", "d_t_t", true),
248-
$("TIME('09:07:00') < DATE('3077-04-12')", "t_d_t", true),
249-
$("DATE('3077-04-12') < TIME('00:00:00')", "d_t_f", false),
248+
$("TIME('09:07:00') < DATE('2242-04-12')", "t_d_t", true),
249+
$("DATE('2242-04-12') < TIME('00:00:00')", "d_t_f", false),
250250
$("TIME('00:00:00') < DATE('2020-09-16')", "t_d_f", false)));
251251
}
252252

@@ -255,14 +255,14 @@ public static Iterable<Object[]> compareLtTimeWithOtherTypes() {
255255
var today = LocalDate.now().toString();
256256
return Arrays.asList(
257257
$$(
258-
$("TIME('22:15:07') < TIMESTAMP('3077-12-15 22:15:07')", "t_ts_t", true),
258+
$("TIME('22:15:07') < TIMESTAMP('2242-12-15 22:15:07')", "t_ts_t", true),
259259
$("TIMESTAMP('1984-12-15 10:20:30') < TIME('10:20:30')", "ts_t_t", true),
260260
$("TIME('10:20:30') < TIMESTAMP('" + today + " 10:20:30')", "t_ts_f", false),
261261
$("TIMESTAMP('" + today + " 20:50:42') < TIME('10:20:30')", "ts_t_f", false),
262-
$("TIME('09:07:00') < DATE('3077-04-12')", "t_d_t", true),
262+
$("TIME('09:07:00') < DATE('2242-04-12')", "t_d_t", true),
263263
$("DATE('2020-09-16') < TIME('09:07:00')", "d_t_t", true),
264264
$("TIME('00:00:00') < DATE('1961-04-12')", "t_d_f", false),
265-
$("DATE('3077-04-12') < TIME('10:20:30')", "d_t_f", false)));
265+
$("DATE('2242-04-12') < TIME('10:20:30')", "d_t_f", false)));
266266
}
267267

268268
@ParametersFactory(argumentFormatting = "%1$s => %3$s")
@@ -274,10 +274,10 @@ public static Iterable<Object[]> compareGtTimestampWithOtherTypes() {
274274
$("DATE('2020-09-16') > TIMESTAMP('2020-09-15 22:15:07')", "d_ts_t", true),
275275
$("TIMESTAMP('2020-09-16 10:20:30') > DATE('2077-04-12')", "ts_d_f", false),
276276
$("DATE('1961-04-12') > TIMESTAMP('1961-04-12 00:00:00')", "d_ts_f", false),
277-
$("TIMESTAMP('3077-07-08 20:20:30') > TIME('10:20:30')", "ts_t_t", true),
277+
$("TIMESTAMP('2242-07-08 20:20:30') > TIME('10:20:30')", "ts_t_t", true),
278278
$("TIME('20:50:40') > TIMESTAMP('" + today + " 10:20:30')", "t_ts_t", true),
279279
$("TIMESTAMP('" + today + " 10:20:30') > TIME('10:20:30')", "ts_t_f", false),
280-
$("TIME('09:07:00') > TIMESTAMP('3077-12-15 22:15:07')", "t_ts_f", false)));
280+
$("TIME('09:07:00') > TIMESTAMP('2242-12-15 22:15:07')", "t_ts_f", false)));
281281
}
282282

283283
@ParametersFactory(argumentFormatting = "%1$s => %3$s")
@@ -288,10 +288,10 @@ public static Iterable<Object[]> compareGtDateWithOtherTypes() {
288288
$("TIMESTAMP('2077-04-12 09:07:00') > DATE('2020-09-16')", "ts_d_t", true),
289289
$("DATE('2020-09-16') > TIMESTAMP('2020-09-16 00:00:00')", "d_ts_f", false),
290290
$("TIMESTAMP('1961-04-12 09:07:00') > DATE('1984-12-15')", "ts_d_f", false),
291-
$("DATE('3077-04-12') > TIME('00:00:00')", "d_t_t", true),
291+
$("DATE('2242-04-12') > TIME('00:00:00')", "d_t_t", true),
292292
$("TIME('00:00:00') > DATE('2020-09-16')", "t_d_t", true),
293293
$("DATE('2020-09-16') > TIME('09:07:00')", "d_t_f", false),
294-
$("TIME('09:07:00') > DATE('3077-04-12')", "t_d_f", false)));
294+
$("TIME('09:07:00') > DATE('2242-04-12')", "t_d_f", false)));
295295
}
296296

297297
@ParametersFactory(argumentFormatting = "%1$s => %3$s")
@@ -304,8 +304,8 @@ public static Iterable<Object[]> compareGtTimeWithOtherTypes() {
304304
$("TIME('10:20:30') > TIMESTAMP('" + today + " 10:20:30')", "t_ts_f", false),
305305
$("TIMESTAMP('1984-12-15 10:20:30') > TIME('10:20:30')", "ts_t_f", false),
306306
$("TIME('00:00:00') > DATE('1961-04-12')", "t_d_t", true),
307-
$("DATE('3077-04-12') > TIME('10:20:30')", "d_t_t", true),
308-
$("TIME('09:07:00') > DATE('3077-04-12')", "t_d_f", false),
307+
$("DATE('2242-04-12') > TIME('10:20:30')", "d_t_t", true),
308+
$("TIME('09:07:00') > DATE('2242-04-12')", "t_d_f", false),
309309
$("DATE('2020-09-16') > TIME('09:07:00')", "d_t_f", false)));
310310
}
311311

@@ -319,8 +319,8 @@ public static Iterable<Object[]> compareLteTimestampWithOtherTypes() {
319319
$("TIMESTAMP('2020-09-16 10:20:30') <= DATE('1961-04-12')", "ts_d_f", false),
320320
$("DATE('2077-04-12') <= TIMESTAMP('1984-12-15 22:15:07')", "d_ts_f", false),
321321
$("TIMESTAMP('" + today + " 10:20:30') <= TIME('10:20:30')", "ts_t_t", true),
322-
$("TIME('09:07:00') <= TIMESTAMP('3077-12-15 22:15:07')", "t_ts_t", true),
323-
$("TIMESTAMP('3077-09-16 10:20:30') <= TIME('09:07:00')", "ts_t_f", false),
322+
$("TIME('09:07:00') <= TIMESTAMP('2242-12-15 22:15:07')", "t_ts_t", true),
323+
$("TIMESTAMP('2242-09-16 10:20:30') <= TIME('09:07:00')", "ts_t_f", false),
324324
$("TIME('20:50:40') <= TIMESTAMP('" + today + " 10:20:30')", "t_ts_f", false)));
325325
}
326326

@@ -333,8 +333,8 @@ public static Iterable<Object[]> compareLteDateWithOtherTypes() {
333333
$("DATE('2020-09-16') <= TIMESTAMP('1961-04-12 09:07:00')", "d_ts_f", false),
334334
$("TIMESTAMP('2077-04-12 09:07:00') <= DATE('2020-09-16')", "ts_d_f", false),
335335
$("DATE('2020-09-16') <= TIME('09:07:00')", "d_t_t", true),
336-
$("TIME('09:07:00') <= DATE('3077-04-12')", "t_d_t", true),
337-
$("DATE('3077-04-12') <= TIME('00:00:00')", "d_t_f", false),
336+
$("TIME('09:07:00') <= DATE('2242-04-12')", "t_d_t", true),
337+
$("DATE('2242-04-12') <= TIME('00:00:00')", "d_t_f", false),
338338
$("TIME('00:00:00') <= DATE('2020-09-16')", "t_d_f", false)));
339339
}
340340

@@ -347,10 +347,10 @@ public static Iterable<Object[]> compareLteTimeWithOtherTypes() {
347347
$("TIMESTAMP('1984-12-15 10:20:30') <= TIME('10:20:30')", "ts_t_t", true),
348348
$("TIME('22:15:07') <= TIMESTAMP('1984-12-15 22:15:07')", "t_ts_f", false),
349349
$("TIMESTAMP('" + today + " 20:50:42') <= TIME('10:20:30')", "ts_t_f", false),
350-
$("TIME('09:07:00') <= DATE('3077-04-12')", "t_d_t", true),
350+
$("TIME('09:07:00') <= DATE('2242-04-12')", "t_d_t", true),
351351
$("DATE('2020-09-16') <= TIME('09:07:00')", "d_t_t", true),
352352
$("TIME('00:00:00') <= DATE('1961-04-12')", "t_d_f", false),
353-
$("DATE('3077-04-12') <= TIME('10:20:30')", "d_t_f", false)));
353+
$("DATE('2242-04-12') <= TIME('10:20:30')", "d_t_f", false)));
354354
}
355355

356356
@ParametersFactory(argumentFormatting = "%1$s => %3$s")
@@ -365,7 +365,7 @@ public static Iterable<Object[]> compareGteTimestampWithOtherTypes() {
365365
$("TIMESTAMP('" + today + " 10:20:30') >= TIME('10:20:30')", "ts_t_t", true),
366366
$("TIME('20:50:40') >= TIMESTAMP('" + today + " 10:20:30')", "t_ts_t", true),
367367
$("TIMESTAMP('1977-07-08 10:20:30') >= TIME('10:20:30')", "ts_t_f", false),
368-
$("TIME('09:07:00') >= TIMESTAMP('3077-12-15 22:15:07')", "t_ts_f", false)));
368+
$("TIME('09:07:00') >= TIMESTAMP('2242-12-15 22:15:07')", "t_ts_f", false)));
369369
}
370370

371371
@ParametersFactory(argumentFormatting = "%1$s => %3$s")
@@ -376,10 +376,10 @@ public static Iterable<Object[]> compareGteDateWithOtherTypes() {
376376
$("TIMESTAMP('2077-04-12 09:07:00') >= DATE('2020-09-16')", "ts_d_t", true),
377377
$("DATE('1961-04-12') >= TIMESTAMP('1961-04-12 09:07:00')", "d_ts_f", false),
378378
$("TIMESTAMP('1961-04-12 09:07:00') >= DATE('1984-12-15')", "ts_d_f", false),
379-
$("DATE('3077-04-12') >= TIME('00:00:00')", "d_t_t", true),
379+
$("DATE('2242-04-12') >= TIME('00:00:00')", "d_t_t", true),
380380
$("TIME('00:00:00') >= DATE('2020-09-16')", "t_d_t", true),
381381
$("DATE('2020-09-16') >= TIME('09:07:00')", "d_t_f", false),
382-
$("TIME('09:07:00') >= DATE('3077-04-12')", "t_d_f", false)));
382+
$("TIME('09:07:00') >= DATE('2242-04-12')", "t_d_f", false)));
383383
}
384384

385385
@ParametersFactory(argumentFormatting = "%1$s => %3$s")
@@ -389,11 +389,11 @@ public static Iterable<Object[]> compareGteTimeWithOtherTypes() {
389389
$$(
390390
$("TIME('10:20:30') >= TIMESTAMP('" + today + " 10:20:30')", "t_ts_t", true),
391391
$("TIMESTAMP('" + today + " 20:50:42') >= TIME('10:20:30')", "ts_t_t", true),
392-
$("TIME('22:15:07') >= TIMESTAMP('3077-12-15 22:15:07')", "t_ts_f", false),
392+
$("TIME('22:15:07') >= TIMESTAMP('2242-12-15 22:15:07')", "t_ts_f", false),
393393
$("TIMESTAMP('1984-12-15 10:20:30') >= TIME('10:20:30')", "ts_t_f", false),
394394
$("TIME('00:00:00') >= DATE('1961-04-12')", "t_d_t", true),
395-
$("DATE('3077-04-12') >= TIME('10:20:30')", "d_t_t", true),
396-
$("TIME('09:07:00') >= DATE('3077-04-12')", "t_d_f", false),
395+
$("DATE('2242-04-12') >= TIME('10:20:30')", "d_t_t", true),
396+
$("TIME('09:07:00') >= DATE('2242-04-12')", "t_d_f", false),
397397
$("DATE('2020-09-16') >= TIME('09:07:00')", "d_t_f", false)));
398398
}
399399

@@ -403,7 +403,7 @@ public void testCompare() throws IOException {
403403
executeQuery(
404404
String.format(
405405
"source=%s | eval `%s` = %s | fields `%s`",
406-
TEST_INDEX_DATATYPE_NONNUMERIC, name, functionCall, name));
406+
TEST_INDEX_DATETIME_SIMPLE, name, functionCall, name));
407407
verifySchema(result, schema(name, null, "boolean"));
408408
verifyDataRows(result, rows(expectedResult));
409409
}

0 commit comments

Comments
 (0)