[9.2] Fix ST_DISTANCE handling of invalid geometry literals that fold to null (#140116) (#140265)#140276
Merged
elasticsearchmachine merged 1 commit intoelastic:9.2from Jan 7, 2026
Conversation
…ll (elastic#140116) (elastic#140265) Occasionally on serverless we see a NullPointerException in parsing a geometry literal within ST_DISTANCE functions. This turned out to be hard to reproduce since we cannot see the original query causing this problem. It has been reported in elastic#138594, including a full stack track confirming that it occurs during planning, while folding literals. It turned out to be reproducible with a query like: ``` ROW point = MV_SLICE(["POINT(0)"], 0, 0)::geo_point | EVAL distance = ST_DISTANCE(point, point) ``` Here the WKT is invalid, and the fold over the MV_SLICE would return literal `null` values, since the inner TO_GEOPOINT function was throwing exceptions (since the WKT was invalid). It turned out that MvSlice was using EvaluatorMapper.fold for folding the children, which returns literal java `null` values, and any function using these values needs to also handle literal nulls. So, `fold()` is expected to explicitly return null values when input is null, and the implementation of fold in StDistance did not do this. This PR now covers all descendents of BinarySpatialFunction: * ST_DISTANCE * ST_INTERSECTS * ST_DISJOINT * ST_CONTAINS * ST_WITHIN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Manual backport of #140265