-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: Geospatial design #38916
base: master
Are you sure you want to change the base?
*: Geospatial design #38916
Conversation
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
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 think the design is ready for review.
* [Detailed Design](#detailed-design) | ||
* [Test Design](#test-design) | ||
* [Functional Tests](#functional-tests) | ||
* [Scenario Tests](#scenario-tests) |
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.
* [Scenario Tests](#scenario-tests) |
|
||
## Introduction | ||
|
||
Add support for storing and working with Geospatial data. |
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.
Maybe be a bit more clear what 'working with' means here, perhaps exemplify with geospatial functions like ...
|
||
The focus is to implement the most used functions that are part of the OpenGIS standards and MySQL first and later on the MySQL specific functions where needed for compatibility. | ||
|
||
#### Phase 1 |
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.
Just to differentiate with 'Data types' support phases.
#### Phase 1 | |
#### Functions support Phase 1 |
|
||
Support for GeoHash functions makes it possible to use regular indexes with generated columns. | ||
|
||
Example of `ST_Geohash()` with MySQL 8.0: |
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.
Should ST_GeoHash()
be included in the "Functions" section above? Or is it to be implemented when adding support for Geospatial indexes?
|
||
As you can see in the example `POINT(1 0)` and `POINT(1.01 0)` have the same prefix. More information about what prefix length gives what precision can be found [on wikipedia](https://en.wikipedia.org/wiki/Geohash#Digits_and_precision_in_km). | ||
|
||
Geohash support is useful both for indexing and compatibility. Implementing this should be relatively easy. However this doesn't fully replace geospatial indexes. |
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.
Is GeoHash()
indexing limited to POINTs? Then I think it can be mentioned as a reason for why it does not fully replace geospatial indexes (which I assume at least should support some kind of bounding box lookup).
|
||
## Impacts & Risks | ||
|
||
This adds a new dependency: [github.com/twpayne/go-geom](https://pkg.go.dev/github.com/twpayne/go-geom). The BSD-2-Clause license should be fine. The basic geometric types in this package are ok, but the features that do things like comparing features, calculating distances etc. are not (yet) on the same level as [Boost.Geometry](https://github.com/boostorg/geometry). This means that we may have to add more dependencies and/or implement some missing features ourselves. |
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 it be possible to use CGO to link to the BOOST C++ geometry library to get very good implementation compatibility with MySQL? (If so, would the boost licence be compatible/usable?
|
||
## Client support | ||
|
||
Working with geospatial data is possible with MySQL Client or mycli. However a GUI tool makes many things much easier. MySQL Workbench has [a spatial viewer](https://dev.mysql.com/blog-archive/mysql-workbench-6-2-spatial-data/) since version 6.2. This works with minimal geospatial support in TiDB. However [DBeaver](https://github.com/dbeaver/dbeaver) has a much more advanced [geospatial viewer](https://dbeaver.com/docs/wiki/Working-with-Spatial-GIS-data/). |
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.
Do you mean that DBeaver does not work with the minimal geospatial support in TiDB?
Co-authored-by: Mattias Jonsson <[email protected]>
Co-authored-by: Mattias Jonsson <[email protected]>
Co-authored-by: Mattias Jonsson <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #38916 +/- ##
=================================================
+ Coverage 62.2486% 79.7611% +17.5124%
=================================================
Files 910 3553 +2643
Lines 290329 1035933 +745604
=================================================
+ Hits 180726 826272 +645546
- Misses 95432 171152 +75720
- Partials 14171 38509 +24338 |
What problem does this PR solve?
Issue Number: ref #6347
Problem Summary:
First draft of a design for geospatial support.
What is changed and how it works?
Check List
Tests
Release note