-
Notifications
You must be signed in to change notification settings - Fork 44
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
feat(bq,sf,rs,pg|quadbin): add function QUADBIN_DISTANCE #457
feat(bq,sf,rs,pg|quadbin): add function QUADBIN_DISTANCE #457
Conversation
This pull request has been linked to Shortcut Story #318681: Missing QUADBIN_DISTANCE in AT. |
|
||
**Description** | ||
|
||
Returns the **Chebyshev distance** between two quadbin indexes. Returns `null` on invalid inputs. |
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.
perhaps "the Chebyshev distance in quadbin cells between two quadbin indexes" ? but I'm not sure, it might be confusing... the Chebyshev distance in number of quadbin cells between two quadbin indexes" ?? I'm not sure yet.
We could also add a comment about both indices needing to be of the same resultion.
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.
On second thought, if the reader understands what Chebyshev distance is (or they have looked it up), they probably have figured out what this that, so we can leave that sentence as it. But I would add:
The origin and destination indices must have the same resolution. Otherwise NULL will be returned.
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.
I'll also had the link to wikipedia as we do in here:
https://github.com/CartoDB/analytics-toolbox-core/blob/bug/sc-318681/missing-quadbin-distance-in-at/clouds/redshift/modules/doc/quadbin/QUADBIN_KRING_DISTANCES.md#L36
**Description** | ||
|
||
Returns the **Chebyshev distance** between two quadbin indexes. Returns `null` on invalid inputs. | ||
|
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.
same as BQ:
The origin and destination indices must have the same resolution. Otherwise NULL will be returned.
NULL | ||
ELSE | ||
GREATEST( | ||
ABS((destination_coords->>'x')::DOUBLE PRECISION - (origin_coords->>'x')::DOUBLE PRECISION), |
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.
minor thing: I guess we could cast the coordinates to to BIGINT as well, right?
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.
Actually the DOUBLE PRECISION was intended here. As I took the approach used in QUADBIN_CENTER
but BIGINT makes more sense, will add it.
**Description** | ||
|
||
Returns the **Chebyshev distance** between two quadbin indexes. Returns `null` on invalid inputs. | ||
|
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.
same as BQ:
The origin and destination indices must have the same resolution. Otherwise NULL will be returned.
**Description** | ||
|
||
Returns the **Chebyshev distance** between two quadbin indexes. Returns `null` on invalid inputs. | ||
|
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.
same as BQ:
The origin and destination indices must have the same resolution. Otherwise NULL will be returned.
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
|
||
**Return type** | ||
|
||
`GEOGRAPHY` |
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.
INT64
|
||
**Return type** | ||
|
||
`GEOGRAPHY` |
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.
BIGINT
|
||
**Return type** | ||
|
||
`GEOGRAPHY` |
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.
BIGINT
|
||
**Return type** | ||
|
||
`GEOGRAPHY` |
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.
BIGINT
Description
Shortcut
Type of change
Acceptance