Skip to content

Commit f406f02

Browse files
Fix release tests after merging geogrid types (#133929)
The PR at #129581 did not carefully check that all tests also work as release tests. This lead to some CI failures, which we are fixing here.
1 parent dd66fee commit f406f02

File tree

2 files changed

+38
-28
lines changed

2 files changed

+38
-28
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/ParsingTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public void testInlineCast() throws IOException {
9393
report.humanReadable(true).prettyPrint();
9494
report.startObject();
9595
List<String> namesAndAliases = new ArrayList<>(DataType.namesAndAliases());
96+
if (EsqlCapabilities.Cap.SPATIAL_GRID_TYPES.isEnabled() == false) {
97+
// Some types do not have a converter function if the capability is disabled
98+
namesAndAliases.removeAll(List.of("geohash", "geotile", "geohex"));
99+
}
96100
Collections.sort(namesAndAliases);
97101
for (String nameOrAlias : namesAndAliases) {
98102
DataType expectedType = DataType.fromNameOrAlias(nameOrAlias);

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import static org.hamcrest.Matchers.equalTo;
6868
import static org.hamcrest.Matchers.instanceOf;
6969
import static org.hamcrest.Matchers.matchesRegex;
70+
import static org.hamcrest.Matchers.startsWith;
7071

7172
//@TestLogging(value = "org.elasticsearch.xpack.esql:TRACE,org.elasticsearch.compute:TRACE", reason = "debug")
7273
public class VerifierTests extends ESTestCase {
@@ -1058,9 +1059,6 @@ public void testSpatialSort() {
10581059
"1:136: cannot sort on cartesian_shape",
10591060
error(prefix + "| EVAL shape = TO_CARTESIANSHAPE(wkt) | limit 5 | sort shape")
10601061
);
1061-
assertEquals("1:143: cannot sort on geohash", error(prefix + "| EVAL grid = ST_GEOHASH(TO_GEOPOINT(wkt),1) | limit 5 | sort grid"));
1062-
assertEquals("1:143: cannot sort on geotile", error(prefix + "| EVAL grid = ST_GEOTILE(TO_GEOPOINT(wkt),1) | limit 5 | sort grid"));
1063-
assertEquals("1:142: cannot sort on geohex", error(prefix + "| EVAL grid = ST_GEOHEX(TO_GEOPOINT(wkt),1) | limit 5 | sort grid"));
10641062
var airports = AnalyzerTestUtils.analyzer(loadMapping("mapping-airports.json", "airports"));
10651063
var airportsWeb = AnalyzerTestUtils.analyzer(loadMapping("mapping-airports_web.json", "airports_web"));
10661064
var countriesBbox = AnalyzerTestUtils.analyzer(loadMapping("mapping-countries_bbox.json", "countries_bbox"));
@@ -1069,15 +1067,19 @@ public void testSpatialSort() {
10691067
assertEquals("1:36: cannot sort on cartesian_point", error("FROM airports_web | LIMIT 5 | sort location", airportsWeb));
10701068
assertEquals("1:38: cannot sort on geo_shape", error("FROM countries_bbox | LIMIT 5 | sort shape", countriesBbox));
10711069
assertEquals("1:42: cannot sort on cartesian_shape", error("FROM countries_bbox_web | LIMIT 5 | sort shape", countriesBboxWeb));
1072-
assertEquals(
1073-
"1:67: cannot sort on geohash",
1074-
error("FROM airports | LIMIT 5 | EVAL g = ST_GEOHASH(location, 1) | sort g", airports)
1075-
);
1076-
assertEquals(
1077-
"1:67: cannot sort on geotile",
1078-
error("FROM airports | LIMIT 5 | EVAL g = ST_GEOTILE(location, 1) | sort g", airports)
1079-
);
1080-
assertEquals("1:66: cannot sort on geohex", error("FROM airports | LIMIT 5 | EVAL g = ST_GEOHEX(location, 1) | sort g", airports));
1070+
for (String grid : new String[] { "geohash", "geotile", "geohex" }) {
1071+
String gridFunc = "ST_" + grid.toUpperCase(Locale.ROOT);
1072+
String literalQuery = prefix + "| EVAL grid = " + gridFunc + "(TO_GEOPOINT(wkt),1) | limit 5 | sort grid";
1073+
String indexQuery = "FROM airports | LIMIT 5 | EVAL grid = " + gridFunc + "(location, 1) | sort grid";
1074+
String literalError = "1:" + (136 + grid.length()) + ": cannot sort on " + grid;
1075+
String indexError = "1:" + (63 + grid.length()) + ": cannot sort on " + grid;
1076+
if (EsqlCapabilities.Cap.SPATIAL_GRID_TYPES.isEnabled() == false) {
1077+
literalError = "1:95: Unknown function [" + gridFunc + "]";
1078+
indexError = "1:39: Unknown function [" + gridFunc + "]";
1079+
}
1080+
assertThat(grid, error(literalQuery), startsWith(literalError));
1081+
assertThat(grid, error(indexQuery, airports), startsWith(indexError));
1082+
}
10811083
}
10821084

10831085
public void testSourceSorting() {
@@ -2073,7 +2075,9 @@ public void testChangePoint() {
20732075
public void testChangePoint_keySortable() {
20742076
assumeTrue("change_point must be enabled", EsqlCapabilities.Cap.CHANGE_POINT.isEnabled());
20752077
List<DataType> sortableTypes = List.of(BOOLEAN, DOUBLE, DATE_NANOS, DATETIME, INTEGER, IP, KEYWORD, LONG, UNSIGNED_LONG, VERSION);
2076-
List<DataType> unsortableTypes = List.of(CARTESIAN_POINT, CARTESIAN_SHAPE, GEO_POINT, GEO_SHAPE, GEOHASH, GEOTILE, GEOHEX);
2078+
List<DataType> unsortableTypes = EsqlCapabilities.Cap.SPATIAL_GRID_TYPES.isEnabled()
2079+
? List.of(CARTESIAN_POINT, CARTESIAN_SHAPE, GEO_POINT, GEO_SHAPE, GEOHASH, GEOTILE, GEOHEX)
2080+
: List.of(CARTESIAN_POINT, CARTESIAN_SHAPE, GEO_POINT, GEO_SHAPE);
20772081
for (DataType type : sortableTypes) {
20782082
query(Strings.format("ROW key=NULL::%s, value=0\n | CHANGE_POINT value ON key", type));
20792083
}
@@ -2088,21 +2092,23 @@ public void testChangePoint_keySortable() {
20882092
public void testChangePoint_valueNumeric() {
20892093
assumeTrue("change_point must be enabled", EsqlCapabilities.Cap.CHANGE_POINT.isEnabled());
20902094
List<DataType> numericTypes = List.of(DOUBLE, INTEGER, LONG, UNSIGNED_LONG);
2091-
List<DataType> nonNumericTypes = List.of(
2092-
BOOLEAN,
2093-
CARTESIAN_POINT,
2094-
CARTESIAN_SHAPE,
2095-
DATE_NANOS,
2096-
DATETIME,
2097-
GEO_POINT,
2098-
GEO_SHAPE,
2099-
GEOHASH,
2100-
GEOTILE,
2101-
GEOHEX,
2102-
IP,
2103-
KEYWORD,
2104-
VERSION
2105-
);
2095+
List<DataType> nonNumericTypes = EsqlCapabilities.Cap.SPATIAL_GRID_TYPES.isEnabled()
2096+
? List.of(
2097+
BOOLEAN,
2098+
CARTESIAN_POINT,
2099+
CARTESIAN_SHAPE,
2100+
DATE_NANOS,
2101+
DATETIME,
2102+
GEO_POINT,
2103+
GEO_SHAPE,
2104+
GEOHASH,
2105+
GEOTILE,
2106+
GEOHEX,
2107+
IP,
2108+
KEYWORD,
2109+
VERSION
2110+
)
2111+
: List.of(BOOLEAN, CARTESIAN_POINT, CARTESIAN_SHAPE, DATE_NANOS, DATETIME, GEO_POINT, GEO_SHAPE, IP, KEYWORD, VERSION);
21062112
for (DataType type : numericTypes) {
21072113
query(Strings.format("ROW key=0, value=NULL::%s\n | CHANGE_POINT value ON key", type));
21082114
}

0 commit comments

Comments
 (0)