Skip to content

Commit 83b035e

Browse files
committed
Fix some GeoPoint test cases
1 parent 6448db9 commit 83b035e

File tree

1 file changed

+11
-10
lines changed
  • x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/fulltext

1 file changed

+11
-10
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/fulltext/DecayTests.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1212

1313
import org.apache.lucene.util.BytesRef;
14+
import org.elasticsearch.common.geo.GeoPoint;
1415
import org.elasticsearch.geometry.Point;
1516
import org.elasticsearch.xpack.esql.core.expression.Expression;
1617
import org.elasticsearch.xpack.esql.core.tree.Source;
@@ -55,10 +56,10 @@ public static Iterable<Object[]> parameters() {
5556

5657
// GeoPoint
5758
testCaseSuppliers.addAll(
58-
geoPointTestCase(new Point(0.0, 0.0), new Point(1.0, 1.0), "200km", "0km", 0.5, "linear", 0.606876005579706)
59+
geoPointTestCase("POINT (1 1)", "POINT (1 1)", "200km", "0km", 0.5, "linear", 1.0)
5960
);
6061
testCaseSuppliers.addAll(
61-
geoPointOffsetKeywordTestCase(new Point(0.0, 0.0), new Point(1.0, 1.0), "200km", "0km", 0.5, "linear", 0.606876005579706)
62+
geoPointOffsetKeywordTestCase("POINT (1 1)", "POINT (1 1)", "200km", "0km", 0.5, "linear", 1.0)
6263
);
6364

6465
// CartesianPoint
@@ -311,8 +312,8 @@ private static List<TestCaseSupplier> doubleTestCase(
311312

312313
// TODO: geo point
313314
private static List<TestCaseSupplier> geoPointTestCase(
314-
Point value,
315-
Point origin,
315+
String valueWkt,
316+
String originWkt,
316317
String scale,
317318
String offset,
318319
double decay,
@@ -324,8 +325,8 @@ private static List<TestCaseSupplier> geoPointTestCase(
324325
List.of(DataType.GEO_POINT, DataType.GEO_POINT, DataType.TEXT, DataType.TEXT, DataType.DOUBLE, DataType.KEYWORD),
325326
() -> new TestCaseSupplier.TestCase(
326327
List.of(
327-
new TestCaseSupplier.TypedData(new BytesRef(GEO.asWkt(value)), DataType.GEO_POINT, "value"),
328-
new TestCaseSupplier.TypedData(new BytesRef(GEO.asWkt(origin)), DataType.GEO_POINT, "origin"),
328+
new TestCaseSupplier.TypedData(GEO.wktToWkb(valueWkt), DataType.GEO_POINT, "value"),
329+
new TestCaseSupplier.TypedData(GEO.wktToWkb(originWkt), DataType.GEO_POINT, "origin"),
329330
new TestCaseSupplier.TypedData(scale, DataType.TEXT, "scale"),
330331
new TestCaseSupplier.TypedData(offset, DataType.TEXT, "offset"),
331332
new TestCaseSupplier.TypedData(decay, DataType.DOUBLE, "decay"),
@@ -340,8 +341,8 @@ private static List<TestCaseSupplier> geoPointTestCase(
340341
}
341342

342343
private static List<TestCaseSupplier> geoPointOffsetKeywordTestCase(
343-
Point value,
344-
Point origin,
344+
String valueWkt,
345+
String originWkt,
345346
String scale,
346347
String offset,
347348
double decay,
@@ -353,8 +354,8 @@ private static List<TestCaseSupplier> geoPointOffsetKeywordTestCase(
353354
List.of(DataType.GEO_POINT, DataType.GEO_POINT, DataType.TEXT, DataType.KEYWORD, DataType.DOUBLE, DataType.KEYWORD),
354355
() -> new TestCaseSupplier.TestCase(
355356
List.of(
356-
new TestCaseSupplier.TypedData(new BytesRef(GEO.asWkt(value)), DataType.GEO_POINT, "value"),
357-
new TestCaseSupplier.TypedData(new BytesRef(GEO.asWkt(origin)), DataType.GEO_POINT, "origin"),
357+
new TestCaseSupplier.TypedData(GEO.wktToWkb(valueWkt), DataType.GEO_POINT, "value"),
358+
new TestCaseSupplier.TypedData(GEO.wktToWkb(originWkt), DataType.GEO_POINT, "origin"),
358359
new TestCaseSupplier.TypedData(scale, DataType.TEXT, "scale"),
359360
new TestCaseSupplier.TypedData(offset, DataType.KEYWORD, "offset"),
360361
new TestCaseSupplier.TypedData(decay, DataType.DOUBLE, "decay"),

0 commit comments

Comments
 (0)