Skip to content

opt: fix normalization of st_distance when use_spheroid parameter used#55739

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rytaft:fix-distance-func
Oct 20, 2020
Merged

opt: fix normalization of st_distance when use_spheroid parameter used#55739
craig[bot] merged 1 commit intocockroachdb:masterfrom
rytaft:fix-distance-func

Conversation

@rytaft
Copy link
Copy Markdown
Collaborator

@rytaft rytaft commented Oct 20, 2020

This commit fixes the normalization rule that converts st_distance to
st_dwithin or st_dwithinexclusive, which was broken in the case when
the use_spheroid parameter was used. Prior to this commit, the rule was
assigning the use_spheroid parameter as the 3rd parameter to st_dwithin
or st_dwithinexclusive and the distance parameter as the 4th, but that
order does not match the function signatures. This commit fixes the issue
by assigning distance as the 3rd parameter and use_spheroid as the 4th
if it exists.

Fixes #55675

Release note (bug fix): Fixed an internal error that could occur during
query planning when the use_spheroid parameter was used in the ST_Distance
function as part of a filter predicate. For example, SELECT ... WHERE ST_Distance(geog1, geog2, false) < 10 previously caused an error. This
has now been fixed.

This commit fixes the normalization rule that converts st_distance to
st_dwithin or st_dwithinexclusive, which was broken in the case when
the use_spheroid parameter was used. Prior to this commit, the rule was
assigning the use_spheroid parameter as the 3rd parameter to st_dwithin
or st_dwithinexclusive and the distance parameter as the 4th, but that
order does not match the function signatures. This commit fixes the issue
by assigning distance as the 3rd parameter and use_spheroid as the 4th
if it exists.

Fixes cockroachdb#55675

Release note (bug fix): Fixed an internal error that could occur during
query planning when the use_spheroid parameter was used in the ST_Distance
function as part of a filter predicate. For example, `SELECT ... WHERE
ST_Distance(geog1, geog2, false) < 10` previously caused an error. This
has now been fixed.
@rytaft rytaft requested a review from otan October 20, 2020 13:01
@rytaft rytaft requested a review from a team as a code owner October 20, 2020 13:01
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@otan otan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooft, thanks!

@rytaft
Copy link
Copy Markdown
Collaborator Author

rytaft commented Oct 20, 2020

TFTR!

bors r+

Copy link
Copy Markdown
Contributor

@mgartner mgartner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Oct 20, 2020

Build succeeded:

@craig craig bot merged commit d58b0dc into cockroachdb:master Oct 20, 2020
@rafiss rafiss added this to the 20.2 milestone Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

roachtest: sqlsmith failure could not find overload for st_dwithinexclusive

5 participants