[Feature][Jdbc] Add String type column split Support by charset-based splitting algorithm#9002
Merged
Conversation
Hisoka-X
reviewed
Mar 20, 2025
Contributor
Author
|
@Hisoka-X Thank you for your review very much. All related issues you pointed out have been corrected. |
Hisoka-X
reviewed
Mar 24, 2025
Comment on lines
+71
to
+72
| | string_split_mode | String | No | - | When set to "charset_based", enables charset-based string splitting algorithm. The algorithm assumes characters of partition_column are within ASCII range 32-126, which covers most character-based splitting scenarios. | | ||
| | string_split_mode_collate | String | No | - | Specifies the collation to use when string_split_mode is set to "charset_based" and the table has a special collation. If not specified, the database's default collation will be used. | |
Member
There was a problem hiding this comment.
Oh, it dawned on me that it might be better to add the split prefix, just like the other sharding parameters.
Suggested change
| | string_split_mode | String | No | - | When set to "charset_based", enables charset-based string splitting algorithm. The algorithm assumes characters of partition_column are within ASCII range 32-126, which covers most character-based splitting scenarios. | | |
| | string_split_mode_collate | String | No | - | Specifies the collation to use when string_split_mode is set to "charset_based" and the table has a special collation. If not specified, the database's default collation will be used. | | |
| | split.string_split_mode | String | No | sample | Supports different string splitting algorithms. By default, `sample` is used to determine the split by sampling the string value. You can switch to `charset_based` to enable charset-based string splitting algorithm. When set to `charset_based`, the algorithm assumes characters of partition_column are within ASCII range 32-126, which covers most character-based splitting scenarios. | | |
| | split.string_split_mode_collate | String | No | - | Specifies the collation to use when string_split_mode is set to `charset_based` and the table has a special collation. If not specified, the database's default collation will be used. | |
Contributor
Author
There was a problem hiding this comment.
you are right, fix done
|
|
||
| private StringSplitMode stringSplitMode; | ||
|
|
||
| private String collate; |
Member
There was a problem hiding this comment.
Suggested change
| private String collate; | |
| private String stringSplitModeCollate; |
added 8 commits
March 24, 2025 11:13
… splitting algorithm
… splitting algorithm
… splitting algorithm
… splitting algorithm
… splitting algorithm
… splitting algorithm
… splitting algorithm
… splitting algorithm
added 7 commits
March 24, 2025 11:17
… splitting algorithm
… splitting algorithm
… splitting algorithm
… splitting algorithm
… splitting algorithm
… splitting algorithm
… splitting algorithm
Hisoka-X
reviewed
Mar 25, 2025
… splitting algorithm
Hisoka-X
approved these changes
Mar 26, 2025
hailin0
approved these changes
Mar 26, 2025
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.
Purpose of this pull request
This PR introduces a new character-based splitting algorithm for JDBC connectors when dealing with string-type columns. The traditional approach for splitting string-type data relies on database limit queries or mod hash operations, which can be inefficient for large datasets. The new algorithm uses character set ordering for more efficient splitting, eliminating the need for multiple database limit queries when MIN and MAX values are already known.
The core algorithm works as follows(org.apache.seatunnel.connectors.seatunnel.jdbc.source.CollationBasedSplitter):
This approach produces evenly distributed string splits without requiring additional database queries, significantly improving performance for large datasets.
Does this PR introduce any user-facing change?
Yes, this PR introduces a new configuration option
string_split_modewhich can be set tocharset_basedto enable the new character set-based string splitting algorithm. Users can also specify thestring_split_mode_collateparameter to define a specific character collation order. If not specified, the database system's default sorting rule will be used.Currently, the implementation supports all visible ASCII characters (code points 32-126), which covers most common use cases for string fields typically composed of numbers and letters.
Recommendation: recommend setting
string_split_mode=charset_basedwhen dealing with large datasets that require many partitions and only have string fields available as split keys. This mode significantly reduces the number of database queries and improves overall performance in these scenarios.How was this patch tested?
The implementation has been tested with:
CollationBasedSplitterclass to verify the conversion between strings and numeric rangesAll tests confirm that the algorithm correctly splits string-type data into evenly distributed chunks and provides significant performance improvements for large datasets.
Check list
release-note.