Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: Add initial geo support #29872

Closed
13 tasks done
elasticmachine opened this issue Mar 8, 2018 · 0 comments
Closed
13 tasks done

SQL: Add initial geo support #29872

elasticmachine opened this issue Mar 8, 2018 · 0 comments

Comments

@elasticmachine
Copy link
Collaborator

elasticmachine commented Mar 8, 2018

Introduction

This is a meta issue for tracking initial iteration of adding geo features to SQL. Our implementation will be based on the OpenGIS® Implementation Standard for Geographic information - Simple feature access, which is the current standard for GIS system implementation. This effort will concentrate on SQL option AKA ISO 19125-2. Later on we might also consider adding support for SQL/MM (ISO 13249-3), which extends Simple Feature Access with circular interpolations.

The current work can be found in the geosql branch.

Initial Implementation plan

This effort will be divided in the following sub-issues

Queries that will be supported in the initial implementation

Initial minimal release should support the following commands:

Metadata commands

  • DESCRIBE table - returns the correct column type GEOMETRY for geo shapes
  • SYS_SPATIAL_REF - returns a table with a single spatial reference system WGS84
  • SYS_GEOMETRY_COLUMNS - returns a list of all geometry columns in all tables

Returning geoshapes and geopoints from elasticsearch

  • SELECT * FROM table - returns the geoshapes in their _source representation;
  • SELECT ST_AsWKT(geom) FROM table; and SELECT ST_AsText(geom) FROM table;- returns the geoshapes in their WKT representation;

Using geopoints to elasticsearch

  • The following functions will be supported for geopoints in queries and aggregations: ST_GeomFromText, "ST_X, ST_Y, ST_Z, ST_Distance`.
  • SELECT * FROM table WHERE ST_Distance(ST_GeomFromText(POINT(1 2), point) < 10; - returns all records for which point is located within 10m from the POINT(1 2) by using 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.

imotov added a commit to imotov/elasticsearch that referenced this issue May 9, 2018
Adds support for SYS GEOMETRY_COLUMNS, which returns the same
information as `SELECT * FROM GEOMETRY_COLUMNS` command in the standard
implementation.

Relates elastic#29872
imotov added a commit that referenced this issue Jun 12, 2018
Adds basic support for geo point type. For now, the geopoint is
represented as a string and returned in the same format it was stored
in the source.

Relates to #29872
imotov added a commit to imotov/elasticsearch that referenced this issue Nov 9, 2018
Adds support for ST_WktToSQL function which accepts a string and parses
it as WKT representation of a geoshape.

Relates to elastic#29872
imotov added a commit that referenced this issue Nov 15, 2018
Adds support for ST_WktToSQL function which accepts a string and parses
it as WKT representation of a geoshape.

Relates to #29872
imotov added a commit to imotov/elasticsearch that referenced this issue Nov 19, 2018
Adds support for ST_Dimension, ST_GeometryType, ST_X, ST_Y, ST_XMin,
ST_XMax, ST_YMin, ST_YMax functions.

Relates to elastic#29872
imotov added a commit to imotov/elasticsearch that referenced this issue Mar 12, 2019
Adds ST_Distance function that works on points. No other shapes
are supported at the moments. No optimization and conversion into
geo_distance filter is done yet.

Relates to elastic#29872
imotov added a commit that referenced this issue Mar 22, 2019
* SQL: Add ST_Distance function to geosql

Adds ST_Distance function that works on points. No other shapes
are supported at the moments. No optimization and conversion into
geo_distance filter is done yet.

Relates to #29872
imotov added a commit that referenced this issue Apr 10, 2019
ST_Distance function returns null now instead of throwing an error
when one of the arguments in null. It also brings the handling of
arrays when a single item is expected in line with the rest of 
data types and fixes the handling of geo_points when docvalues
are not available.

Relates to #29872
imotov added a commit to imotov/elasticsearch that referenced this issue Apr 11, 2019
Adds 3 new geosql functions. The ST_Z functions as well as ST_X and
ST_Y functions for polygons are not supported because of the issues
described in elastic#40908. The suppor will be added as soon as the
ShapeBuilder issues are resolved.

Relates to elastic#29872
imotov added a commit that referenced this issue Apr 22, 2019
Adds 3 new geosql functions. The ST_Z functions as well as ST_X and
ST_Y functions for polygons are not supported because of the issues
described in #40908. This support will be added as soon as the
ShapeBuilder issues are resolved.

Relates to #29872
imotov added a commit that referenced this issue Apr 29, 2019
Adds GeoJson parser for Geometry classes defined in libs/geo.

Relates #40908 and #29872
imotov added a commit to imotov/elasticsearch that referenced this issue Apr 29, 2019
Adds GeoJson parser for Geometry classes defined in libs/geo.

Relates elastic#40908 and elastic#29872
imotov added a commit that referenced this issue Apr 29, 2019
Adds GeoJson parser for Geometry classes defined in libs/geo.

Relates #40908 and #29872
imotov added a commit to imotov/elasticsearch that referenced this issue Apr 30, 2019
Switches the server side of the geosql processing from using
ShapeBuilder to libs/geo geometry objects.

Relates to elastic#29872
akhil10x5 pushed a commit to akhil10x5/elasticsearch that referenced this issue May 2, 2019
Adds GeoJson parser for Geometry classes defined in libs/geo.

Relates elastic#40908 and elastic#29872
imotov added a commit that referenced this issue May 2, 2019
)

Switches the server side of the geosql processing from using
ShapeBuilder to libs/geo geometry objects.

Relates to #29872
imotov added a commit that referenced this issue May 6, 2019
Adds support for the ST_Z function that returns the altitude of the
first point in a shape.

Relates to #29872
imotov added a commit that referenced this issue May 14, 2019
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](http://www.opengeospatial.org/standards/sfs), 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 types `GEOMETRY` for geo shapes and geo points.
- `SHOW FUNCTIONS` - returns a list that includes supported `ST_` functions
- `SYS TYPES` and `SYS COLUMNS` display correct types `GEO_SHAPE` and `GEO_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;` and `SELECT ST_AsText(geom) FROM table;`- returns the geoshapes ang geopoints in their WKT representation;

### Using geopoints to elasticsearch

- The following functions will be supported for geopoints in queries, sorting and aggregations: `ST_GeomFromText`, `ST_X`, `ST_Y`, `ST_Z`, `ST_GeometryType`, and `ST_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 which `point` is located within 10m from the `POINT(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
imotov added a commit to imotov/elasticsearch that referenced this issue May 14, 2019
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](http://www.opengeospatial.org/standards/sfs), which is the current standard for GIS system implementation. This effort is concentrate on SQL option AKA ISO 19125-2.

- `DESCRIBE table`  - returns the correct column types `GEOMETRY` for geo shapes and geo points.
- `SHOW FUNCTIONS` - returns a list that includes supported `ST_` functions
- `SYS TYPES` and `SYS COLUMNS` display correct types `GEO_SHAPE` and `GEO_POINT` for geo shapes and geo points accordingly.

- `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;` and `SELECT ST_AsText(geom) FROM table;`- returns the geoshapes ang geopoints in their WKT representation;

- The following functions will be supported for geopoints in queries, sorting and aggregations: `ST_GeomFromText`, `ST_X`, `ST_Y`, `ST_Z`, `ST_GeometryType`, and `ST_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 which `point` is located within 10m from the `POINT(1 2)`. In this case the WHERE clause is translated into a range query.

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 elastic#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 elastic#29872
imotov added a commit that referenced this issue May 14, 2019
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](http://www.opengeospatial.org/standards/sfs), 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 types `GEOMETRY` for geo shapes and geo points.
- `SHOW FUNCTIONS` - returns a list that includes supported `ST_` functions
- `SYS TYPES` and `SYS COLUMNS` display correct types `GEO_SHAPE` and `GEO_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;` and `SELECT ST_AsText(geom) FROM table;`- returns the geoshapes ang geopoints in their WKT representation;

Using geopoints to elasticsearch

- The following functions will be supported for geopoints in queries, sorting and aggregations: `ST_GeomFromText`, `ST_X`, `ST_Y`, `ST_Z`, `ST_GeometryType`, and `ST_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 which `point` is located within 10m from the `POINT(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
@bpintea bpintea closed this as completed May 18, 2019
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this issue May 27, 2019
Adds GeoJson parser for Geometry classes defined in libs/geo.

Relates elastic#40908 and elastic#29872
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this issue May 27, 2019
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](http://www.opengeospatial.org/standards/sfs), 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 types `GEOMETRY` for geo shapes and geo points.
- `SHOW FUNCTIONS` - returns a list that includes supported `ST_` functions
- `SYS TYPES` and `SYS COLUMNS` display correct types `GEO_SHAPE` and `GEO_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;` and `SELECT ST_AsText(geom) FROM table;`- returns the geoshapes ang geopoints in their WKT representation;

### Using geopoints to elasticsearch

- The following functions will be supported for geopoints in queries, sorting and aggregations: `ST_GeomFromText`, `ST_X`, `ST_Y`, `ST_Z`, `ST_GeometryType`, and `ST_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 which `point` is located within 10m from the `POINT(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 elastic#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 elastic#29872
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants