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: Handling of coerced WKT polygons #43173

Closed
imotov opened this issue Jun 12, 2019 · 2 comments · Fixed by #43273
Closed

SQL: Handling of coerced WKT polygons #43173

imotov opened this issue Jun 12, 2019 · 2 comments · Fixed by #43273
Assignees
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes :Analytics/SQL SQL querying >bug

Comments

@imotov
Copy link
Contributor

imotov commented Jun 12, 2019

WKT parser in SQL cannot handle polygons that were represented in WKT and are not closed, which can be stored if coerce flag in mapping is set to true but then cannot be retrieved in SQL. That's not an issue for polygons stored in GeoJSON. To reproduce:

DELETE test

PUT test 
{
  "mappings": {
    "properties": {
      "shape": {
        "type": "geo_shape",
        "coerce": true
      }
    }
  }
}

PUT test/_doc/1
{
  "shape": "POLYGON ((1 1, -1 1, -1 -1, 1 -1))"
}

POST _sql
{
  "query": "SELECT * FROM test"
}

The last command will return an error:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "first and last points of the linear ring must be the same (it must close itself): lats[0]=1.0 lats[3]=-1.0 lons[0]=1.0 lons[3]=1.0"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "first and last points of the linear ring must be the same (it must close itself): lats[0]=1.0 lats[3]=-1.0 lons[0]=1.0 lons[3]=1.0"
  },
  "status": 400
}
@imotov imotov added >bug :Analytics/Geo Indexing, search aggregations of geo points and shapes :Analytics/SQL SQL querying labels Jun 12, 2019
@imotov imotov self-assigned this Jun 12, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

imotov added a commit to imotov/elasticsearch that referenced this issue Jun 17, 2019
Adds support for coercing not closed polygons and ignoring Z value
to libs/geo WKT parser.

Closes elastic#43173
imotov added a commit that referenced this issue Jun 18, 2019
Adds support for coercing not closed polygons and ignoring Z value
to libs/geo WKT parser.

Closes #43173
imotov added a commit that referenced this issue Jun 18, 2019
Adds support for coercing not closed polygons and ignoring Z value
to libs/geo WKT parser.

Closes #43173
imotov added a commit to imotov/elasticsearch that referenced this issue Jun 19, 2019
Adds support for coercing not closed polygons and ignoring Z value
to libs/geo WKT parser.

Closes elastic#43173
imotov added a commit that referenced this issue Jun 25, 2019
…3367)

Adds support for coercing not closed polygons and ignoring Z value
to libs/geo WKT parser.

Backport of #42549 and #43273
Closes #43173
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes :Analytics/SQL SQL querying >bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants