SQL: Add initial geo support - 7.x #42135
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds an initial limited implementations of geo features to SQL. This implementation is based on the OpenGIS® Implementation Standard for Geographic information - Simple feature access, which is the current standard for GIS system implementation. This effort is concentrate on SQL option AKA ISO 19125-2.
Queries that are supported as a result of this initial implementation
Metadata commands
DESCRIBE table
- returns the correct column typesGEOMETRY
for geo shapes and geo points.SHOW FUNCTIONS
- returns a list that includes supportedST_
functionsSYS TYPES
andSYS COLUMNS
display correct typesGEO_SHAPE
andGEO_POINT
for geo shapes and geo points accordingly.Returning geoshapes and geopoints from elasticsearch
SELECT geom FROM table
- returns the geoshapes and geo_points as libs/geo objects in JDBC or as WKT strings in console.SELECT ST_AsWKT(geom) FROM table;
andSELECT ST_AsText(geom) FROM table;
- returns the geoshapes ang geopoints in their WKT representation;Using geopoints to elasticsearch
ST_GeomFromText
,ST_X
,ST_Y
,ST_Z
,ST_GeometryType
, andST_Distance
. In most cases when used in queries, sorting and aggregations, these function are translated into script. These functions can be used in the SELECT clause for both geopoints and geoshapes.SELECT * FROM table WHERE ST_Distance(ST_GeomFromText(POINT(1 2), point) < 10;
- returns all records for whichpoint
is located within 10m from thePOINT(1 2)
. In this case the WHERE clause is translated into a range query.Limitations:
Geoshapes cannot be used in queries, sorting and aggregations as part of this initial effort. In order to fully take advantage of geoshapes we would need to have access to geoshape doc values, which is coming in #37206.
ST_Z
cannot be used on geopoints in queries, sorting and aggregations since we don't store altitude in geo_point doc values.Relates to #29872
Backport of #42031