Skip to content

Commit 3587573

Browse files
committed
Remove license checking mechanism from tests (unsupported in 8.x)
1 parent de57aed commit 3587573

File tree

11 files changed

+15
-66
lines changed

11 files changed

+15
-66
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialGridFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ protected static void addGrids(LongBlock.Builder results, List<Long> gridIds) {
208208
if (gridIds.isEmpty()) {
209209
results.appendNull();
210210
} else if (gridIds.size() == 1) {
211-
results.appendLong(gridIds.getFirst());
211+
results.appendLong(gridIds.get(0));
212212
} else {
213213
results.beginPositionEntry();
214214
for (long gridId : gridIds) {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohashToLong.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public class StGeohashToLong extends AbstractConvertFunction implements Evaluato
4444
@FunctionInfo(
4545
returnType = "long",
4646
description = "Converts an input value representing a geohash grid-ID in string format into a long.",
47-
examples = { @Example(file = "spatial-grid", tag = "geohash_to_long") },
48-
depthOffset = 1 // make it appear as a subsection of ST_GEOHASH
47+
examples = { @Example(file = "spatial-grid", tag = "geohash_to_long") }
4948
)
5049
public StGeohashToLong(
5150
Source source,

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohashToString.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public class StGeohashToString extends AbstractConvertFunction implements Evalua
4444
@FunctionInfo(
4545
returnType = "keyword",
4646
description = "Converts an input value representing a geohash grid-ID in long format into a string.",
47-
examples = { @Example(file = "spatial-grid", tag = "geohash_to_string") },
48-
depthOffset = 1 // make it appear as a subsection of ST_GEOHASH
47+
examples = { @Example(file = "spatial-grid", tag = "geohash_to_string") }
4948
)
5049
public StGeohashToString(
5150
Source source,

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohexToLong.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public class StGeohexToLong extends AbstractConvertFunction implements Evaluator
4444
@FunctionInfo(
4545
returnType = "long",
4646
description = "Converts an input value representing a geohex grid-ID in string format into a long.",
47-
examples = { @Example(file = "spatial-grid", tag = "geohex_to_long") },
48-
depthOffset = 1 // make it appear as a subsection of ST_GEOHEX
47+
examples = { @Example(file = "spatial-grid", tag = "geohex_to_long") }
4948
)
5049
public StGeohexToLong(
5150
Source source,

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohexToString.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public class StGeohexToString extends AbstractConvertFunction implements Evaluat
4444
@FunctionInfo(
4545
returnType = "keyword",
4646
description = "Converts an input value representing a Geohex grid-ID in long format into a string.",
47-
examples = { @Example(file = "spatial-grid", tag = "geohex_to_string") },
48-
depthOffset = 1 // make it appear as a subsection of ST_GEOHEX
47+
examples = { @Example(file = "spatial-grid", tag = "geohex_to_string") }
4948
)
5049
public StGeohexToString(
5150
Source source,

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeotileToLong.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public class StGeotileToLong extends AbstractConvertFunction implements Evaluato
4444
@FunctionInfo(
4545
returnType = "long",
4646
description = "Converts an input value representing a geotile grid-ID in string format into a long.",
47-
examples = { @Example(file = "spatial-grid", tag = "geotile_to_long") },
48-
depthOffset = 1 // make it appear as a subsection of ST_GEOTILE
47+
examples = { @Example(file = "spatial-grid", tag = "geotile_to_long") }
4948
)
5049
public StGeotileToLong(
5150
Source source,

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeotileToString.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public class StGeotileToString extends AbstractConvertFunction implements Evalua
4444
@FunctionInfo(
4545
returnType = "keyword",
4646
description = "Converts an input value representing a geotile grid-ID in long format into a string.",
47-
examples = { @Example(file = "spatial-grid", tag = "geotile_to_string") },
48-
depthOffset = 1 // make it appear as a subsection of ST_GEOTILE
47+
examples = { @Example(file = "spatial-grid", tag = "geotile_to_string") }
4948
)
5049
public StGeotileToString(
5150
Source source,

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialGridFunctionTestCase.java

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.elasticsearch.compute.operator.EvalOperator;
1414
import org.elasticsearch.geometry.Point;
1515
import org.elasticsearch.geometry.Rectangle;
16-
import org.elasticsearch.license.License;
1716
import org.elasticsearch.xpack.esql.core.expression.Literal;
1817
import org.elasticsearch.xpack.esql.core.tree.Source;
1918
import org.elasticsearch.xpack.esql.core.type.DataType;
@@ -41,26 +40,6 @@ protected interface TriFunction<T, U, V, R> {
4140
R apply(T t, U u, V v);
4241
}
4342

44-
/**
45-
* All spatial grid functions have one license requirement in common, and that is that they are licensed aty PLATINUM level
46-
* oif the spatial field is a shape, otherwise they are licensed at BASIC level. This is to mimic the license requirements
47-
* of the spatial aggregations.
48-
* @param fieldTypes (null for the function itself, otherwise a map of field named to types)
49-
* @return The license requirement for the function with that type signature
50-
*/
51-
protected static License.OperationMode licenseRequirement(List<DataType> fieldTypes) {
52-
if (fieldTypes == null || fieldTypes.isEmpty()) {
53-
// The function itself is not licensed, but the field types are.
54-
return License.OperationMode.BASIC;
55-
}
56-
if (DataType.isSpatialShape(fieldTypes.getFirst())) {
57-
// Only aggregations over shapes are licensed under platinum.
58-
return License.OperationMode.PLATINUM;
59-
}
60-
// All other field types are licensed under basic.
61-
return License.OperationMode.BASIC;
62-
}
63-
6443
private static String getFunctionClassName() {
6544
Class<?> testClass = getTestClass();
6645
String testClassName = testClass.getSimpleName();
@@ -126,23 +105,23 @@ protected static void addTestCaseSuppliers(
126105
public static TestCaseSupplier.TypedDataSupplier testCaseSupplier(DataType dataType, boolean pointsOnly) {
127106
if (pointsOnly) {
128107
return switch (dataType.esType()) {
129-
case "geo_point" -> TestCaseSupplier.geoPointCases(() -> false).getFirst();
130-
case "cartesian_point" -> TestCaseSupplier.cartesianPointCases(() -> false).getFirst();
108+
case "geo_point" -> TestCaseSupplier.geoPointCases(() -> false).get(0);
109+
case "cartesian_point" -> TestCaseSupplier.cartesianPointCases(() -> false).get(0);
131110
default -> throw new IllegalArgumentException("Unsupported datatype for " + functionName() + ": " + dataType);
132111
};
133112
} else {
134113
return switch (dataType.esType()) {
135-
case "geo_point" -> TestCaseSupplier.geoPointCases(() -> false).getFirst();
136-
case "geo_shape" -> TestCaseSupplier.geoShapeCases(() -> false).getFirst();
137-
case "cartesian_point" -> TestCaseSupplier.cartesianPointCases(() -> false).getFirst();
138-
case "cartesian_shape" -> TestCaseSupplier.cartesianShapeCases(() -> false).getFirst();
114+
case "geo_point" -> TestCaseSupplier.geoPointCases(() -> false).get(0);
115+
case "geo_shape" -> TestCaseSupplier.geoShapeCases(() -> false).get(0);
116+
case "cartesian_point" -> TestCaseSupplier.cartesianPointCases(() -> false).get(0);
117+
case "cartesian_shape" -> TestCaseSupplier.cartesianShapeCases(() -> false).get(0);
139118
default -> throw new IllegalArgumentException("Unsupported datatype for " + functionName() + ": " + dataType);
140119
};
141120
}
142121
}
143122

144123
protected Long process(int precision, BiFunction<BytesRef, Integer, Long> expectedValue) {
145-
Object spatialObj = this.testCase.getDataValues().getFirst();
124+
Object spatialObj = this.testCase.getDataValues().get(0);
146125
assumeNotNull(spatialObj);
147126
assumeTrue("Expected a BytesRef, but got " + spatialObj.getClass(), spatialObj instanceof BytesRef);
148127
BytesRef wkb = (BytesRef) spatialObj;
@@ -157,7 +136,7 @@ protected Long process(int precision, BiFunction<BytesRef, Integer, Long> expect
157136
}
158137

159138
protected Long process(BytesRef bounds, BiFunction<BytesRef, BytesRef, Long> expectedValue) {
160-
Object spatialObj = this.testCase.getDataValues().getFirst();
139+
Object spatialObj = this.testCase.getDataValues().get(0);
161140
assumeNotNull(spatialObj);
162141
assumeTrue("Expected a BytesRef, but got " + spatialObj.getClass(), spatialObj instanceof BytesRef);
163142
BytesRef wkb = (BytesRef) spatialObj;

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohashTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ public StGeohashTests(@Name("TestCase") Supplier<TestCaseSupplier.TestCase> test
3131
this.testCase = testCaseSupplier.get();
3232
}
3333

34-
/**
35-
* Since geo grid functions are primarily used for spatial aggregations,
36-
* we use the same license requirement as the spatial aggregations.
37-
*/
38-
public static License.OperationMode licenseRequirement(List<DataType> fieldTypes) {
39-
return SpatialGridFunctionTestCase.licenseRequirement(fieldTypes);
40-
}
41-
4234
@ParametersFactory
4335
public static Iterable<Object[]> parameters() {
4436
final List<TestCaseSupplier> suppliers = new ArrayList<>();

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohexTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ public StGeohexTests(@Name("TestCase") Supplier<TestCaseSupplier.TestCase> testC
3131
this.testCase = testCaseSupplier.get();
3232
}
3333

34-
/**
35-
* Other geo grid functions use the same type-specific license requirement as the spatial aggregations, but geohex is licensed
36-
* more strictly, at platinum for all field types.
37-
*/
38-
public static License.OperationMode licenseRequirement(List<DataType> fieldTypes) {
39-
return License.OperationMode.PLATINUM;
40-
}
41-
4234
@ParametersFactory
4335
public static Iterable<Object[]> parameters() {
4436
final List<TestCaseSupplier> suppliers = new ArrayList<>();

0 commit comments

Comments
 (0)