-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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 basic support for ST_AsWKT geo function #34205
SQL: Add basic support for ST_AsWKT geo function #34205
Conversation
Adds basic support for ST_AsWKT function. The function takes accepts geo shape or geo point and returns its WKT representation.
Pinging @elastic/es-search-aggs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good. I really only have one question re: o.e.xpack.sql.expression.function.scalar.geo.GeoShape. It looks to be mostly just a wrapper around .toWKT and ShapeParser.parse. Is it necessary? Could we move this class to o.e.common.geo? That might give a good starting point for consolidating in the move to BKD backed geoshapes? I'm also okay w/ doing this is a future PR.
Great work!
/** | ||
* Wrapper class to represent a GeoShape in SQL | ||
*/ | ||
public class GeoShape implements ToXContentFragment { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, is this class necessary for the SQL plugin? It seems to mostly be a wrapper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wrapper overrides the XContent serialization to use WKT instead of GeoJSON, which is default representation on the SQL side. So, now that I am thinking about it I am not sure if it makes sense to move this to sql package as we previously discussed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, no problem. We can take a closer look at moving things around after we get BKD backed shapes committed so I'm not too worried about this atm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Left a comment about adding more tests.
; | ||
|
||
selectWithAsWKTInWhere | ||
SELECT city, ST_ASWKT(location) location, region FROM "geo" WHERE LOCATE('114', ST_ASWKT(location)) > 0 ORDER BY "city"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add more tests that use the new functions in ORDER BY, GROUP BY and HAVING? This should test the Painless script in various setups. Same goes for tests using these functions inside other functions or the input of these functions to come from other functions, useful for testing folding.
You should, probably, add documentation for these functions as well. |
Adds additional tests and documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Adds basic support for ST_AsWKT function. The function takes accepts
geo shape or geo point and returns its WKT representation.