Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,11 @@ public enum Index {
"_doc",
getDataTypeNonnumericIndexMapping(),
"src/test/resources/datatypes.json"),
DATETIME_SIMPLE(
TestsConstants.TEST_INDEX_DATETIME_SIMPLE,
"_doc",
getDateTimeSimpleIndexMapping(),
"src/test/resources/datetime_simple.json"),
BEER(
TestsConstants.TEST_INDEX_BEER, "beer", null, "src/test/resources/beer.stackexchange.json"),
NULL_MISSING(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ public static String getDataTypeNonnumericIndexMapping() {
return getMappingFile(mappingFile);
}

public static String getDateTimeSimpleIndexMapping() {
String mappingFile = "datetime_simple_index_mapping.json";
return getMappingFile(mappingFile);
}

public static String getGeopointIndexMapping() {
String mappingFile = "geopoint_index_mapping.json";
return getMappingFile(mappingFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class TestsConstants {
public static final String TEST_INDEX_STRINGS = TEST_INDEX + "_strings";
public static final String TEST_INDEX_DATATYPE_NUMERIC = TEST_INDEX + "_datatypes_numeric";
public static final String TEST_INDEX_DATATYPE_NONNUMERIC = TEST_INDEX + "_datatypes_nonnumeric";
public static final String TEST_INDEX_DATETIME_SIMPLE = TEST_INDEX + "_datetime_simple";
public static final String TEST_INDEX_BEER = TEST_INDEX + "_beer";
public static final String TEST_INDEX_NULL_MISSING = TEST_INDEX + "_null_missing";
public static final String TEST_INDEX_CALCS = TEST_INDEX + "_calcs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import static com.carrotsearch.randomizedtesting.RandomizedTest.$;
import static com.carrotsearch.randomizedtesting.RandomizedTest.$$;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DATATYPE_NONNUMERIC;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DATETIME_SIMPLE;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.schema;
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
Expand All @@ -28,7 +28,7 @@ public class DateTimeComparisonIT extends PPLIntegTestCase {
@Override
public void init() throws Exception {
super.init();
loadIndex(Index.DATA_TYPE_NONNUMERIC);
loadIndex(Index.DATETIME_SIMPLE);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

qq: does the sql variant's testCompare actually need this index loaded? scrolling down to the method body, it is just select <expr> AS <name> with no FROM clause, so i don't think this load is reaching any query.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

lol, probably. i think it's just copied from ppl maybe since ppl doesn't support bare queries without indices. won't rock the boat with it though

}

private final TimeZone testTz = TimeZone.getDefault();
Expand Down Expand Up @@ -231,7 +231,7 @@ public static Iterable<Object[]> compareLtTimestampWithOtherTypes() {
$("TIMESTAMP('2020-09-16 10:20:30') < DATE('1961-04-12')", "ts_d_f", false),
$("DATE('2020-09-16') < TIMESTAMP('2020-09-16 00:00:00')", "d_ts_f", false),
$("TIMESTAMP('2020-09-16 10:20:30') < TIME('09:07:00')", "ts_t_t", true),
$("TIME('09:07:00') < TIMESTAMP('3077-12-15 22:15:07')", "t_ts_t", true),
$("TIME('09:07:00') < TIMESTAMP('2242-12-15 22:15:07')", "t_ts_t", true),
$("TIMESTAMP('" + today + " 10:20:30') < TIME('10:20:30')", "ts_t_f", false),
$("TIME('20:50:40') < TIMESTAMP('" + today + " 10:20:30')", "t_ts_f", false)));
}
Expand All @@ -240,13 +240,13 @@ public static Iterable<Object[]> compareLtTimestampWithOtherTypes() {
public static Iterable<Object[]> compareLtDateWithOtherTypes() {
return Arrays.asList(
$$(
$("DATE('2020-09-16') < TIMESTAMP('3077-04-12 09:07:00')", "d_ts_t", true),
$("DATE('2020-09-16') < TIMESTAMP('2242-04-12 09:07:00')", "d_ts_t", true),
$("TIMESTAMP('1961-04-12 09:07:00') < DATE('1984-12-15')", "ts_d_t", true),
$("DATE('2020-09-16') < TIMESTAMP('2020-09-16 00:00:00')", "d_ts_f", false),
$("TIMESTAMP('2077-04-12 09:07:00') < DATE('2020-09-16')", "ts_d_f", false),
$("DATE('2020-09-16') < TIME('09:07:00')", "d_t_t", true),
$("TIME('09:07:00') < DATE('3077-04-12')", "t_d_t", true),
$("DATE('3077-04-12') < TIME('00:00:00')", "d_t_f", false),
$("TIME('09:07:00') < DATE('2242-04-12')", "t_d_t", true),
$("DATE('2242-04-12') < TIME('00:00:00')", "d_t_f", false),
$("TIME('00:00:00') < DATE('2020-09-16')", "t_d_f", false)));
}

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

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

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

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

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

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

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

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

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

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

Expand All @@ -403,7 +403,7 @@ public void testCompare() throws IOException {
executeQuery(
String.format(
"source=%s | eval `%s` = %s | fields `%s`",
TEST_INDEX_DATATYPE_NONNUMERIC, name, functionCall, name));
TEST_INDEX_DATETIME_SIMPLE, name, functionCall, name));
verifySchema(result, schema(name, null, "boolean"));
verifyDataRows(result, rows(expectedResult));
}
Expand Down
Loading
Loading