Skip to content

Commit d63465e

Browse files
committed
Added ST_GEOXXX_TO_LONG, _TO_STRING and _TO_GEOSHAPE functions
This is because we want to move the ST_GEOXXX functions to produce longs only, for performance reasons, and need the convenience functions to display these either as strings or as actual shapes. This is both useful to the users, as well as easier to do manual tests where we visualize the results on a map.
1 parent b25c207 commit d63465e

25 files changed

+2602
-2
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/resources/spatial-grid.csv-spec

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,50 @@
22
# Tests for geo_grid function: ST_GEOHASH
33
###############################################
44

5+
geohashStringToLong
6+
required_capability: spatial_grid
7+
8+
ROW geohash = "u3bu"
9+
| EVAL geohashLong = ST_GEOHASH_TO_LONG(geohash)
10+
;
11+
12+
geohash:keyword | geohashLong:long
13+
u3bu | 13686180
14+
;
15+
16+
geohashLongToString
17+
required_capability: spatial_grid
18+
19+
ROW geohash = TO_LONG(13686180)
20+
| EVAL geohashString = ST_GEOHASH_TO_STRING(geohash)
21+
;
22+
23+
geohash:long | geohashString:keyword
24+
13686180 | u3bu
25+
;
26+
27+
geohashStringToGeoShape
28+
required_capability: spatial_grid
29+
30+
ROW geohash = "u3bu"
31+
| EVAL boundary = ST_GEOHASH_TO_GEOSHAPE(geohash)
32+
;
33+
34+
geohash:keyword | boundary:geo_shape
35+
u3bu | BBOX (12.3046875, 12.65625, 55.72265625, 55.546875)
36+
;
37+
38+
geohashLongToGeoShape
39+
required_capability: spatial_grid
40+
41+
ROW geohash = TO_LONG(13686180)
42+
| EVAL boundary = ST_GEOHASH_TO_GEOSHAPE(geohash)
43+
;
44+
45+
geohash:long | boundary:geo_shape
46+
13686180 | BBOX (12.3046875, 12.65625, 55.72265625, 55.546875)
47+
;
48+
549
geohashLiteral
650
required_capability: spatial_grid
751

@@ -190,6 +234,19 @@ count:long | centroid:geo_point
190234
# Tests for geo_grid function: ST_GEOTILE
191235
###############################################
192236

237+
geotileStringToLong
238+
required_capability: spatial_grid
239+
240+
ROW geotile = "4/8/5"
241+
| EVAL geotileLong = ST_GEOTILE_TO_LONG(geotile)
242+
| EVAL geotileString = ST_GEOTILE_TO_STRING(geotileLong)
243+
| EVAL boundary = ST_GEOTILE_TO_GEOSHAPE(geotile)
244+
;
245+
246+
geotile:keyword | geotileLong:long | geotileString:keyword | boundary:geo_shape
247+
4/8/5 | 1152921508901814277 | 4/8/5 | BBOX (0.0, 22.5, 55.77657301866769, 40.979898069620134)
248+
;
249+
193250
geotileLiteral
194251
required_capability: spatial_grid
195252

@@ -361,6 +418,19 @@ count:long | centroid:geo_point
361418
# Tests for geo_grid function: ST_GEOHEX
362419
###############################################
363420

421+
geohexStringToLong
422+
required_capability: spatial_grid
423+
424+
ROW geohex = "841f059ffffffff"
425+
| EVAL geohexLong = ST_GEOHEX_TO_LONG(geohex)
426+
| EVAL geohexString = ST_GEOHEX_TO_STRING(geohexLong)
427+
| EVAL boundary = ST_GEOHEX_TO_GEOSHAPE(geohex)
428+
;
429+
430+
geohex:keyword | geohexLong:long | geohexString:keyword | boundary:geo_shape
431+
841f059ffffffff | 595020895127339007 | 841f059ffffffff | POLYGON ((12.353546327258265 55.80335405461356, 12.2434612967008 55.60502874054935, 12.51733872608954 55.470800201545316, 12.901880149865134 55.53443156197633, 13.014270156228921 55.73262985778208, 12.739822958959069 55.8673267391136, 12.353546327258265 55.80335405461356))
432+
;
433+
364434
geohexLiteral
365435
required_capability: spatial_grid
366436

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

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 125 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)