Skip to content

Commit 712696e

Browse files
committed
Add support for optional bounds parameter
1 parent 5bfb23e commit 712696e

14 files changed

+1177
-247
lines changed

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,26 @@ count:long | centroid:geo_point | geohash:keyword
7878
// end::st_geohash-grid-result[]
7979
;
8080

81+
gridGeohashStatsByBounds
82+
FROM airports
83+
| EVAL geohash = ST_GEOHASH(location, 2, TO_GEOSHAPE("BBOX(0, 12, 60, 30)"))
84+
| WHERE geohash IS NOT NULL
85+
| STATS
86+
count = COUNT(*),
87+
centroid = ST_CENTROID_AGG(location)
88+
BY geohash
89+
| SORT count DESC, geohash ASC
90+
;
91+
92+
count:long | centroid:geo_point | geohash:keyword
93+
19 | POINT (6.360728044651057 47.94084087577894) | u0
94+
8 | POINT (6.351574736181647 51.8981519783847) | u1
95+
7 | POINT (5.268637698941997 42.747250193330856) | sp
96+
4 | POINT (7.7012718468904495 36.39783004182391) | sn
97+
2 | POINT (11.7787727387622 48.351816879585385) | u2
98+
1 | POINT (5.629810290411115 58.88215648010373) | u4
99+
;
100+
81101
gridGeohashStatsByWhereUK
82102
FROM airports
83103
| WHERE ST_INTERSECTS(location, TO_GEOSHAPE("POLYGON((1.2305 60.8449, -1.582 61.6899, -10.7227 58.4017, -7.1191 55.3291, -7.9102 54.2139, -5.4492 54.0078, -5.2734 52.3756, -7.8223 49.6676, -5.0977 49.2678, 0.9668 50.5134, 2.5488 52.1065, 2.6367 54.0078, -0.9668 56.4625, 1.2305 60.8449))"))
@@ -94,6 +114,24 @@ count:long | centroid:geo_point | geohash:keyword
94114
3 | POINT (-2.7510103583335876 58.79020635969937) | gf
95115
;
96116

117+
gridGeohashStatsByBoundsUK
118+
FROM airports
119+
| EVAL bounds = ST_ENVELOPE(TO_GEOSHAPE("POLYGON((1.2305 60.8449, -1.582 61.6899, -10.7227 58.4017, -7.1191 55.3291, -7.9102 54.2139, -5.4492 54.0078, -5.2734 52.3756, -7.8223 49.6676, -5.0977 49.2678, 0.9668 50.5134, 2.5488 52.1065, 2.6367 54.0078, -0.9668 56.4625, 1.2305 60.8449))"))
120+
| EVAL geohash = ST_GEOHASH(location, 2, bounds)
121+
| WHERE geohash IS NOT NULL
122+
| STATS
123+
count = COUNT(location),
124+
centroid = ST_CENTROID_AGG(location)
125+
BY geohash
126+
| SORT count DESC
127+
;
128+
129+
count:long | centroid:geo_point | geohash:keyword
130+
17 | POINT (-3.5034258844440473 53.25306422789307) | gc
131+
3 | POINT (-2.7510103583335876 58.79020635969937) | gf
132+
1 | POINT (0.15865350142121315 49.36166098807007) | u0
133+
;
134+
97135
gridGeohashInStatsBy
98136
FROM airports
99137
| STATS

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

Lines changed: 139 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/StGeohashFromFieldAndFieldEvaluator.java

Lines changed: 7 additions & 37 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/StGeohashFromFieldAndLiteralAndLiteralEvaluator.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)