33###############################################
44
55geohashLiteral
6+ required_capability: spatial_grid
7+
68ROW location = TO_GEOPOINT("POINT(12.6493508684508 55.6285017221528)")
79| EVAL geohash4 = ST_GEOHASH(location, 4),
810 geohash3 = ST_GEOHASH(location, 3),
@@ -15,6 +17,8 @@ POINT(12.6493508684508 55.6285017221528) | u3bu | u3b | u3 | u
1517;
1618
1719geohashLiteralMv
20+ required_capability: spatial_grid
21+
1822ROW location = TO_GEOPOINT("POINT(12.6493508684508 55.6285017221528)"), precision = [1,2,3,4,5]
1923| MV_EXPAND precision
2024| EVAL geohash = ST_GEOHASH(location, precision)
@@ -29,6 +33,8 @@ POINT (12.6493508684508 55.6285017221528) | 5 | u3bur
2933;
3034
3135geohashField
36+ required_capability: spatial_grid
37+
3238FROM airports
3339| WHERE abbrev == "CPH"
3440| EVAL geohash = ST_GEOHASH(location, 7)
@@ -41,6 +47,8 @@ u3buryf | CPH | Copenhagen | POINT (12.6493508684508 55.62850
4147
4248gridGeohashStatsBy
4349// tag::st_geohash-grid[]
50+ required_capability: spatial_grid
51+
4452FROM airports
4553| EVAL geohash = ST_GEOHASH(location, 1)
4654| STATS
@@ -75,6 +83,8 @@ count:long | centroid:geo_point | geohash:keyword
7583;
7684
7785gridGeohashStatsByBounds
86+ required_capability: spatial_grid
87+
7888FROM airports
7989| EVAL geohash = ST_GEOHASH(location, 2, TO_GEOSHAPE("BBOX(0, 12, 60, 30)"))
8090| WHERE geohash IS NOT NULL
@@ -95,6 +105,8 @@ count:long | centroid:geo_point | geohash:keyword
95105;
96106
97107gridGeohashStatsByWhereUK
108+ required_capability: spatial_grid
109+
98110FROM airports
99111| 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))"))
100112| EVAL geohash = ST_GEOHASH(location, 2)
@@ -111,6 +123,8 @@ count:long | centroid:geo_point | geohash:keyword
111123;
112124
113125gridGeohashStatsByBoundsUK
126+ required_capability: spatial_grid
127+
114128FROM airports
115129| 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))"))
116130| EVAL geohash = ST_GEOHASH(location, 2, bounds)
@@ -129,6 +143,8 @@ count:long | centroid:geo_point | geohash:keyword
129143;
130144
131145gridGeohashInStatsBy
146+ required_capability: spatial_grid
147+
132148FROM airports
133149| STATS
134150 count = COUNT(location),
@@ -153,6 +169,8 @@ count:long | centroid:geo_point
153169;
154170
155171gridGeohashInStatsByWhereUK
172+ required_capability: spatial_grid
173+
156174FROM airports
157175| 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))"))
158176| STATS
@@ -173,6 +191,8 @@ count:long | centroid:geo_point
173191###############################################
174192
175193geotileLiteral
194+ required_capability: spatial_grid
195+
176196ROW location = TO_GEOPOINT("POINT(12.6493508684508 55.6285017221528)")
177197| EVAL geotile4 = ST_GEOTILE(location, 4),
178198 geotile3 = ST_GEOTILE(location, 3),
@@ -185,6 +205,8 @@ POINT (12.6493508684508 55.6285017221528) | 4/8/5 | 3/4/2
185205;
186206
187207geotileLiteralMv
208+ required_capability: spatial_grid
209+
188210ROW location = TO_GEOPOINT("POINT(12.6493508684508 55.6285017221528)"), precision = [1,2,3,4,5]
189211| MV_EXPAND precision
190212| EVAL geotile = ST_GEOTILE(location, precision)
@@ -199,6 +221,8 @@ POINT (12.6493508684508 55.6285017221528) | 5 | 5/17/10
199221;
200222
201223geotileField
224+ required_capability: spatial_grid
225+
202226FROM airports
203227| WHERE abbrev == "CPH"
204228| EVAL geotile = ST_GEOTILE(location, 7)
@@ -211,6 +235,8 @@ geotile:keyword | abbrev:keyword | name:text | location:geo_point
211235
212236gridGeotileStatsBy
213237// tag::st_geotile-grid[]
238+ required_capability: spatial_grid
239+
214240FROM airports
215241| EVAL geotile = ST_GEOTILE(location, 2)
216242| STATS
@@ -238,6 +264,8 @@ count:long | centroid:geo_point | geotile:keyword
238264;
239265
240266gridGeotileStatsByBounds
267+ required_capability: spatial_grid
268+
241269FROM airports
242270| EVAL geotile = ST_GEOTILE(location, 3, TO_GEOSHAPE("BBOX(0, 12, 60, 30)"))
243271| WHERE geotile IS NOT NULL
@@ -254,6 +282,8 @@ count:long | centroid:geo_point | geotile:keyword
254282;
255283
256284gridGeotileStatsByWhereUK
285+ required_capability: spatial_grid
286+
257287FROM airports
258288| 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))"))
259289| EVAL geotile = ST_GEOTILE(location, 4)
@@ -270,6 +300,8 @@ count:long | centroid:geo_point | geotile:keyword
270300;
271301
272302gridGeotileStatsByBoundsUK
303+ required_capability: spatial_grid
304+
273305FROM airports
274306| 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))"))
275307| EVAL geotile = ST_GEOTILE(location, 2, bounds)
@@ -287,6 +319,8 @@ count:long | centroid:geo_point | geotile:keyword
287319;
288320
289321gridGeotileInStatsBy
322+ required_capability: spatial_grid
323+
290324FROM airports
291325| STATS
292326 count = COUNT(location),
@@ -305,6 +339,8 @@ count:long | centroid:geo_point
305339;
306340
307341gridGeotileInStatsByWhereUK
342+ required_capability: spatial_grid
343+
308344FROM airports
309345| 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))"))
310346| STATS
@@ -324,6 +360,8 @@ count:long | centroid:geo_point
324360###############################################
325361
326362geohexLiteral
363+ required_capability: spatial_grid
364+
327365ROW location = TO_GEOPOINT("POINT(12.6493508684508 55.6285017221528)")
328366| EVAL geohex4 = ST_GEOHEX(location, 4),
329367 geohex3 = ST_GEOHEX(location, 3),
@@ -336,6 +374,8 @@ POINT (12.6493508684508 55.6285017221528) | 841f059ffffffff | 831f05fffffffff |
336374;
337375
338376geohexLiteralMv
377+ required_capability: spatial_grid
378+
339379ROW location = TO_GEOPOINT("POINT(12.6493508684508 55.6285017221528)"), precision = [1,2,3,4,5]
340380| MV_EXPAND precision
341381| EVAL geohex = ST_GEOHEX(location, precision)
@@ -350,6 +390,8 @@ POINT (12.6493508684508 55.6285017221528) | 5 | 851f0583fffffff
350390;
351391
352392geohexField
393+ required_capability: spatial_grid
394+
353395FROM airports
354396| WHERE abbrev == "CPH"
355397| EVAL geohex = ST_GEOHEX(location, 7)
@@ -362,6 +404,8 @@ geohex:keyword | abbrev:keyword | name:text | location:geo_point
362404
363405gridGeohexStatsBy
364406// tag::st_geohex-grid[]
407+ required_capability: spatial_grid
408+
365409FROM airports
366410| EVAL geohex = ST_GEOHEX(location, 1)
367411| STATS
@@ -390,6 +434,8 @@ count:long | centroid:geo_point | geohex:keyword
390434;
391435
392436gridGeohexStatsByBounds
437+ required_capability: spatial_grid
438+
393439FROM airports
394440| EVAL geohex = ST_GEOHEX(location, 1, TO_GEOSHAPE("BBOX(0, 12, 60, 30)"))
395441| WHERE geohex IS NOT NULL
@@ -413,6 +459,8 @@ count:long | centroid:geo_point | geohex:keyword
413459;
414460
415461gridGeohexStatsByWhereUK
462+ required_capability: spatial_grid
463+
416464FROM airports
417465| 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))"))
418466| EVAL geohex = ST_GEOHEX(location, 1)
@@ -431,6 +479,8 @@ count:long | centroid:geo_point | geohex:keyword
431479;
432480
433481gridGeohexStatsByBoundsUK
482+ required_capability: spatial_grid
483+
434484FROM airports
435485| 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))"))
436486| EVAL geohex = ST_GEOHEX(location, 2, bounds)
@@ -455,44 +505,41 @@ count:long | centroid:geo_point | geohex:keyword
4555051 | POINT (-0.16296171583235264 51.1557567352429) | 82194ffffffffff
456506;
457507
458- gridGeohexInStatsBy
508+ gridGeohexInStatsByBounds
509+ required_capability: spatial_grid
510+
459511FROM airports
460512| STATS
461513 count = COUNT(location),
462514 centroid = ST_CENTROID_AGG(location)
463- BY ST_GEOHEX(location, 1)
515+ BY ST_GEOHEX(location, 2, TO_GEOSHAPE("BBOX(0, 12, 60, 30)"))
516+ | WHERE count > 3
464517| SORT count DESC
465518| KEEP count, centroid
466519| LIMIT 10
467520;
468521
469- count:long | centroid:geo_point
470- 22 | POINT (7.250850197689777 48.21363834643059)
471- 18 | POINT (-80.64959161449224 40.04119813675061)
472- 17 | POINT (-0.7606179875266903 52.86413913565304)
473- 13 | POINT (22.53157936179867 41.98255742864254)
474- 13 | POINT (78.30096947387435 26.073904778951636)
475- 12 | POINT (-100.30120467301458 20.114154297625646)
476- 12 | POINT (-76.39781514415517 45.16300531569868)
477- 11 | POINT (-99.4237939513881 27.100012352774765)
478- 11 | POINT (-83.42379064553164 33.18388901439241)
479- 11 | POINT (18.037187419831753 48.66540593306788)
522+ count:long | centroid:geo_point
523+ 850 | POINT (-0.347950274354833 23.284863485719132)
524+ 6 | POINT (5.582276992499828 50.72238312335685)
525+ 5 | POINT (8.6918301936239 45.19817395694554)
480526;
481527
482528gridGeohexInStatsByWhereUK
529+ required_capability: spatial_grid
530+
483531FROM airports
484532| 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))"))
485533| STATS
486534 count = COUNT(location),
487535 centroid = ST_CENTROID_AGG(location)
488536 BY ST_GEOHEX(location, 1)
537+ | WHERE count > 1
489538| KEEP count, centroid
490539| SORT count DESC
491540;
492541
493542count:long | centroid:geo_point
49454313 | POINT (-2.283508819169723 53.28242553254733)
4955442 | POINT (-3.482485176064074 58.24696456314996)
496- 1 | POINT (-6.216169511899352 54.66155751608312)
497- 1 | POINT (-1.2880607228726149 59.87668995279819)
498545;
0 commit comments