Skip to content

Commit 424c1cd

Browse files
committed
Modified tests to look at capabilities instead of snapshot/release
1 parent 2884174 commit 424c1cd

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

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

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

88
package org.elasticsearch.xpack.esql.analysis;
99

10-
import org.elasticsearch.Build;
1110
import org.elasticsearch.core.PathUtils;
1211
import org.elasticsearch.test.ESTestCase;
1312
import org.elasticsearch.xcontent.XContentBuilder;
@@ -94,8 +93,8 @@ public void testInlineCast() throws IOException {
9493
report.humanReadable(true).prettyPrint();
9594
report.startObject();
9695
List<String> namesAndAliases = new ArrayList<>(DataType.namesAndAliases());
97-
if (Build.current().isSnapshot() == false) {
98-
// Some types do not have a converter in release builds
96+
if (EsqlCapabilities.Cap.SPATIAL_GRID_TYPES.isEnabled() == false) {
97+
// Some types do not have a converter function if the capability is disabled
9998
namesAndAliases.removeAll(List.of("geohash", "geotile", "geohex"));
10099
}
101100
Collections.sort(namesAndAliases);

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,18 +1069,16 @@ public void testSpatialSort() {
10691069
assertEquals("1:42: cannot sort on cartesian_shape", error("FROM countries_bbox_web | LIMIT 5 | sort shape", countriesBboxWeb));
10701070
for (String grid : new String[] { "geohash", "geotile", "geohex" }) {
10711071
String gridFunc = "ST_" + grid.toUpperCase(Locale.ROOT);
1072-
String error = Build.current().isSnapshot()
1073-
? "1:" + (136 + grid.length()) + ": cannot sort on " + grid
1074-
: "1:95: Unknown function [" + gridFunc + "]";
1075-
assertThat(grid, error(prefix + "| EVAL grid = " + gridFunc + "(TO_GEOPOINT(wkt),1) | limit 5 | sort grid"), startsWith(error));
1076-
error = Build.current().isSnapshot()
1077-
? "1:" + (63 + grid.length()) + ": cannot sort on " + grid
1078-
: "1:39: Unknown function [" + gridFunc + "]";
1079-
assertThat(
1080-
grid,
1081-
error("FROM airports | LIMIT 5 | EVAL grid = " + gridFunc + "(location, 1) | sort grid", airports),
1082-
startsWith(error)
1083-
);
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));
10841082
}
10851083
}
10861084

@@ -2077,7 +2075,7 @@ public void testChangePoint() {
20772075
public void testChangePoint_keySortable() {
20782076
assumeTrue("change_point must be enabled", EsqlCapabilities.Cap.CHANGE_POINT.isEnabled());
20792077
List<DataType> sortableTypes = List.of(BOOLEAN, DOUBLE, DATE_NANOS, DATETIME, INTEGER, IP, KEYWORD, LONG, UNSIGNED_LONG, VERSION);
2080-
List<DataType> unsortableTypes = Build.current().isSnapshot()
2078+
List<DataType> unsortableTypes = EsqlCapabilities.Cap.SPATIAL_GRID_TYPES.isEnabled()
20812079
? List.of(CARTESIAN_POINT, CARTESIAN_SHAPE, GEO_POINT, GEO_SHAPE, GEOHASH, GEOTILE, GEOHEX)
20822080
: List.of(CARTESIAN_POINT, CARTESIAN_SHAPE, GEO_POINT, GEO_SHAPE);
20832081
for (DataType type : sortableTypes) {
@@ -2094,7 +2092,7 @@ public void testChangePoint_keySortable() {
20942092
public void testChangePoint_valueNumeric() {
20952093
assumeTrue("change_point must be enabled", EsqlCapabilities.Cap.CHANGE_POINT.isEnabled());
20962094
List<DataType> numericTypes = List.of(DOUBLE, INTEGER, LONG, UNSIGNED_LONG);
2097-
List<DataType> nonNumericTypes = Build.current().isSnapshot()
2095+
List<DataType> nonNumericTypes = EsqlCapabilities.Cap.SPATIAL_GRID_TYPES.isEnabled()
20982096
? List.of(
20992097
BOOLEAN,
21002098
CARTESIAN_POINT,

0 commit comments

Comments
 (0)