-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Support geohash, geotile and geohex grid types in ST_INTERSECTS #133546
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
Support geohash, geotile and geohex grid types in ST_INTERSECTS #133546
Conversation
…search into esql_geogrid_types
Added EsqlCapabily to block older BWC Changed license IT to new API
…search into esql_geogrid_types
The previous support kept the underlying IntBlock, which later would cause exceptions since the type expected a LongBock.
…search into esql_geogrid_types
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Hi @craigtaverner, I've created a changelog YAML for you. |
Disjoint was performing the same check as INTERSECTS, instead of the converse check
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.
80% review here
...a/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/BinarySpatialFunction.java
Show resolved
Hide resolved
...a/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/BinarySpatialFunction.java
Show resolved
Hide resolved
) Expression left, | ||
@Param( | ||
name = "geomB", | ||
type = { "geo_point", "cartesian_point", "geo_shape", "cartesian_shape", "geohash", "geotile", "geohex" }, |
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 capability is in snapshot mode, but the docs will be productive, as well as the type resolution. Is that right? If they will all be snapshot, should we add some snapshot check in resolveType()? (I didn't see it at least). Or maybe set it as preview instead of snapshot, and add an appliesTo
to the docs?
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.
So we had a discussion about this in the previous PR. Making the docs generation snapshot aware is a much bigger lift. The previous PR leaks the types into several functions (TO_STRING, TO_LONG, and TO_GEOSHAPE in particular, but many more). The plan is to move this out of snapshot as soon as this new ST_INTERSECTS PR is merged (and give a couple of days to bake).
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.
We have applies_to
for functions, but not for types. This is a subtle issue really, and we should discuss whether we should invest in applies_to support, or even snapshot support, for types. Right now neither option exists.
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.
Would an applies_to with preview (Or any other tag) work here, even if it's not "snaspshot" explicitly (We can add it in the description (?)).
Thinking not just about the snapshot period, but about the next release, as we'll have to add an appliesTo for the new version anyway (If I'm understanding the new docs correctly)
ℹ️ Important: Docs version tagging👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version. We use applies_to tags to mark version-specific features and changes. Expand for a quick overviewWhen to use applies_to tags:✅ At the page level to indicate which products/deployments the content applies to (mandatory) What NOT to do:❌ Don't remove or replace information that applies to an older version 🤔 Need help?
|
} | ||
} | ||
|
||
protected boolean compareGeometryAndGrid(Geometry geometry, long gridId, DataType gridType) { |
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.
nit: Should this method be abstract and implemented in the specific classes? Both to move special logics out of this base class, and to avoid forgetting it (Or not finding the places to update) when adding grid to WITHIN and CONTAINS
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.
Sounds like a nice idea. But at the moment only CONTAINS has a concrete sub-class, and all others (INTERSECTS, DISJOINT and WITHIN) are operating entirely in the base class. This is because CONTAINS has some special non-standard behaviour forced on us by Lucene. We could create new sub-classes specifically for dealing with the new geo-grids (and therefor remove one switch
statement for the grids code path), but I think the performance optimization is negligable at this point. For performance, the best value for money would be to support Lucene pushdown. Perhaps once I add support for CONTAINS/WITHIN or shapes, it will make the move to multiple sub-classes more worth while?
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.
We already have the subclasses (SpatialIntersects and SpatialDisjoint, as well as the others). I was thinking about moving the method there, to have all the logic related with each of them in the functions.
Are you talking about other subclasses?
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.
Ah, this method compareGeometryAndGrid
is in the SpatialRelatesFunction
class which has only one subclass for CONTAINS. It does not have a reference to the original SpatialIntersects
or other function classes, so cannot call methods on that. I could think of two ways of getting a function into those classes, either making it static (in which case we still need a switch here) or by passing a reference down into this class. Both approaches seem a little too complex. I think I'll defer considering options here until we support either shapes or contains/within, which might motivate for a refactoring, but even then I suspect the current approach might still be a little cleaner.
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!
} | ||
} | ||
|
||
protected boolean compareGeometryAndGrid(Geometry geometry, long gridId, DataType gridType) { |
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.
We already have the subclasses (SpatialIntersects and SpatialDisjoint, as well as the others). I was thinking about moving the method there, to have all the logic related with each of them in the functions.
Are you talking about other subclasses?
In the work at #129581 we added new geo-grid types:
GEOHASH
,GEOTILE
andGEOHEX
, as well as support functions for creating these fromgeo_point
,long
andkeyword
.However, one of the key use cases we wish to replicate from the Query DSL is the grid search, and this involves the need to include the grid id inside a search predicate, in particular the
ST_INTERSECTS
function. For example: