Skip to content
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

Support custom JdbcReadWithPartitionsHelper #31733

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

Amar3tto
Copy link
Contributor

@Amar3tto Amar3tto commented Jul 1, 2024

Fixes #27120


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@Amar3tto Amar3tto marked this pull request as ready for review July 1, 2024 11:20
@Amar3tto
Copy link
Contributor Author

Amar3tto commented Jul 1, 2024

R: @Abacn

Copy link
Contributor

github-actions bot commented Jul 1, 2024

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

Copy link
Contributor

@Abacn Abacn left a comment

Choose a reason for hiding this comment

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

Sorry not aware there are duplicate GitHub Issue, I got a duplicate open PR #31702

@@ -443,7 +442,7 @@ private static Calendar withTimestampAndTimezone(DateTime dateTime) {
*
* @param <PartitionT>
*/
interface JdbcReadWithPartitionsHelper<PartitionT>
public interface JdbcReadWithPartitionsHelper<PartitionT>
Copy link
Contributor

Choose a reason for hiding this comment

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

JdbcUtil is still package private. One would not be able to instantiate JdbcReadWithPartitionsHelper outside the same package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@Amar3tto Amar3tto force-pushed the jdbc-read-with-partitions-helper branch from df0a896 to 094dc70 Compare July 2, 2024 11:13
@Amar3tto Amar3tto requested a review from Abacn July 2, 2024 11:15
public Iterable<KV<String, String>> calculateRanges(
String lowerBoundStr, String upperBoundStr, Long partitions) {
List<KV<String, String>> ranges = new ArrayList<>();
long lowerBound = Long.parseLong(lowerBoundStr);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a bad partition logic. I was doing this also in #31702 at the beginning. However it turns out that this does not read all rows. suppose we have "0" to "999", and partition into 2 strips, it will become "0" - "500"; "501" to "1000", however "501" > "1000", and "9" > "500" in string comparison.

If go with this PR, could you please integrate the test added in #31702. It can also be an example of custom string type partition helper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Amar3tto Amar3tto force-pushed the jdbc-read-with-partitions-helper branch from 094dc70 to f10e29b Compare July 2, 2024 15:47
@Amar3tto Amar3tto requested a review from Abacn July 2, 2024 15:48
@Abacn Abacn merged commit 209d50e into apache:master Jul 2, 2024
19 checks passed
acrites pushed a commit to acrites/beam that referenced this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: allow users to provide their own JdbcReadWithPartitionsHelper
2 participants