-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support Float as primary key for Mysql source #3016
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
base: main
Are you sure you want to change the base?
Support Float as primary key for Mysql source #3016
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
|
||
| private static Float splitFloats(Float start, Float end) { | ||
| if (start == null && end == null) { | ||
| return null; |
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.
BoundarySplitter interface comments does not specify what should be the behavior when both start and end parameters are null :
- Implementations must not assume that that start is less than end. It depends on the
specific ordering used by the database schema.- Implementations must be overflow safe.
- Implementations must guarantee that the splitter is idempotent. The same boundary must get
same split point through the lifetime of the migration.- Implementations must guarantee that the database would teat the splitpoint as being
in-between the start and end as per the ordering and collation used for the partition
column.
Line 40 in ef38a80
| public interface BoundarySplitter<T extends Serializable> extends Serializable { |
For consistency, I then followed the behavior used by other split functions:
When both start and end params are null the split functions return null.
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.
That's right.
...google/cloud/teleport/v2/source/reader/io/jdbc/dialectadapter/mysql/MysqlDialectAdapter.java
Show resolved
Hide resolved
… mapped a IndexType.OTHER)
|
|
||
| // If signs are different, simple addition is safe from overflow | ||
| // because the values cancel each other out towards zero. | ||
| if ((start < 0 && end > 0) || (start > 0 && end < 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.
For float and double we also need to enhance isSplittable to stop the splitting at appropriate precision.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3016 +/- ##
============================================
+ Coverage 50.25% 55.36% +5.10%
+ Complexity 5021 1623 -3398
============================================
Files 967 465 -502
Lines 59261 26060 -33201
Branches 6458 2734 -3724
============================================
- Hits 29783 14427 -15356
+ Misses 27374 10760 -16614
+ Partials 2104 873 -1231
🚀 New features to boost your workflow:
|
In the SourceDB -> Spanner flow, add support for Float type primary key for Mysql source.
UniformSplitter: Add a boundary extractor and splitter (split the range of value in 2) for Float value
Because Float is an approximate values, we need additional changes:
DataflowTemplates/v2/sourcedb-to-spanner/src/main/java/com/google/cloud/teleport/v2/source/reader/io/jdbc/uniformsplitter/range/PartitionColumn.java
Line 26 in a73e0f0
Source IndexType: Add a new IndexType.Float which map internally to Java Float.class
MysqlDialectAdapter: Map Mysql source FLOAT column type to the newly created IndexType above
Add Integration tests in v2/sourcedb-to-spanner/src/test/resources/DataTypesIT