Skip to content

[BEAM-11408] Integrate BigQuery sink streaming inserts with GroupIntoBatches - #13496

Merged
pabloem merged 5 commits into
apache:masterfrom
nehsyc:bq-integration-java
Jan 28, 2021
Merged

[BEAM-11408] Integrate BigQuery sink streaming inserts with GroupIntoBatches#13496
pabloem merged 5 commits into
apache:masterfrom
nehsyc:bq-integration-java

Conversation

@nehsyc

@nehsycnehsyc commented Dec 7, 2020

Copy link
Copy Markdown
Contributor

Use GroupIntoBatches.WithShardedKey API to group and batch write before streaming to BigQuery service. Currently batching is done best-effort on bundle finalization.

This PR

  • adds an option to BigQueryOptions to toggle between the existing and new implementation;
  • extracts the shared code between the old and new implementation to a class BatchedStreamingWrite and provides an option to choose the implementation.

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

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • 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.

Post-Commit Tests Status (on master branch)

LangSDKDataflowFlinkSamzaSparkTwister2
GoBuild Status---Build Status---Build Status---
JavaBuild StatusBuild Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build StatusBuild Status
Build Status
Build Status
Build Status
PythonBuild Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
---Build Status---
XLangBuild StatusBuild StatusBuild Status---Build Status---

Pre-Commit Tests Status (on master branch)

---JavaPythonGoWebsiteWhitespaceTypescript
Non-portableBuild StatusBuild Status
Build Status
Build Status
Build Status
Build StatusBuild StatusBuild StatusBuild Status
Portable---Build Status------------

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

@nehsyc

Copy link
Copy Markdown
ContributorAuthor

R: @reuvenlax@chamikaramj

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Not sure about this limit. What would be a proper value? Should we make it configurable?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

to be hones, I am not sure what's a good duration either. I think this is acceptable for now, until we find out more. Thoughts?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Yeah sounds reasonable to proceed with this for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We are relying on the fact that the GroupIntoBatches produces stable output. Really we should tag this with RequiresStableInput. Can you find out if this is safe to do in Dataflow?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

There is a transform override in Dataflow to add a preceding Reshuffle to DoFns marked with RequiresStableInput.

The override is disabled though. So I guess currently Dataflow does nothing for this tag.

/* TODO[Beam-4684]: Support @RequiresStableInput on Dataflow in a more intelligent way

Also my understanding is that dding a Reshuffle before GroupIntoBatches will introduce an extra shuffle as Reshuffle is essentially a GBK + value expansion in Dataflow.

@nehsyc
nehsycforce-pushed the bq-integration-java branch 2 times, most recently from f8790e3 to 0ab05d9CompareJanuary 9, 2021 00:52
@nehsyc
nehsyc requested a review from reuvenlaxJanuary 11, 2021 17:37
@nehsyc

Copy link
Copy Markdown
ContributorAuthor

@reuvenlax I also have changes for FILE_LOADS ready in my local branch. If it is ok for you, I can merge those into this PR. Otherwise I will send a follow-up PR.

@nehsyc

Copy link
Copy Markdown
ContributorAuthor

R: @pabloem

@nehsyc

Copy link
Copy Markdown
ContributorAuthor

R: @pabloem

Hey Pablo, let me know if it is ok for you to include the changes in FILE_LOADS in this PR as well. If so, I will push a new commit.

@pabloem

Copy link
Copy Markdown
Member

Run Java PostCommit

@pabloem

Copy link
Copy Markdown
Member

Run Java PreCommit

@pabloem

Copy link
Copy Markdown
Member

There are a couple checkstyle warnings on Precommit:

[ant:checkstyle] [ERROR] /home/jenkins/jenkins-slave/workspace/beam_PreCommit_Java_Phrase/src/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BatchedStreamingWrite.java:85:24: Name 'LOG' must match pattern '^[a-z][a-zA-Z0-9]*$'. [MemberName] | | [ant:checkstyle] [ERROR] /home/jenkins/jenkins-slave/workspace/beam_PreCommit_Java_Phrase/src/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BatchedStreamingWrite.java:279:28: Name 'BATCH_MAX_BUFFERING_DURATION' must match pattern '^[a-z][a-zA-Z0-9]*$'. [MemberName]

These mean that the variables should be static to have CAPITALIZED_NAMES, or should be named with camelCase if they are not static. Can you fix that?

Also, it seems there are some merge conflicts. Can you fix that as well?

The last thing to figure out is how to address Reuven's comment regarding stable input

@nehsyc
nehsycforce-pushed the bq-integration-java branch from 0ab05d9 to c033215CompareJanuary 27, 2021 22:31
@pabloem

Copy link
Copy Markdown
Member

Run Java PostCommit

@pabloem

Copy link
Copy Markdown
Member

Run Java_Examples_Dataflow_Java11 PreCommit

@nehsyc

Copy link
Copy Markdown
ContributorAuthor

There are a couple checkstyle warnings on Precommit:

[ant:checkstyle] [ERROR] /home/jenkins/jenkins-slave/workspace/beam_PreCommit_Java_Phrase/src/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BatchedStreamingWrite.java:85:24: Name 'LOG' must match pattern '^[a-z][a-zA-Z0-9]*$'. [MemberName] | | [ant:checkstyle] [ERROR] /home/jenkins/jenkins-slave/workspace/beam_PreCommit_Java_Phrase/src/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BatchedStreamingWrite.java:279:28: Name 'BATCH_MAX_BUFFERING_DURATION' must match pattern '^[a-z][a-zA-Z0-9]*$'. [MemberName]

These mean that the variables should be static to have CAPITALIZED_NAMES, or should be named with camelCase if they are not static. Can you fix that?

Thanks for pointing out! Pushed a commit to fix those.

Also, it seems there are some merge conflicts. Can you fix that as well?

Done.

The last thing to figure out is how to address Reuven's comment regarding stable input

Based on my understanding Dataflow currently doesn't do anything for @RequiresStableInputs so it may be considered as safe for now but if we add naive support like a Reshuffle it would be adding duplicated shuffles. How about adding a TODO here so we don't forget?

@pabloem

Copy link
Copy Markdown
Member

@pabloem

Copy link
Copy Markdown
Member

Run Java PostCommit

@pabloem

Copy link
Copy Markdown
Member

Run Java PreCommit

@pabloem

Copy link
Copy Markdown
Member

Postcommit from previous commit: https://ci-beam.apache.org/job/beam_PostCommit_Java_PR/558/

@pabloem
pabloem merged commit f0a3f6d into apache:masterJan 28, 2021
@pabloem

Copy link
Copy Markdown
Member

Thanks @nehsyc !

nehsyc added a commit to nehsyc/beam that referenced this pull request Jan 28, 2021
…sink streaming inserts with GroupIntoBatches
* Integrate BQ streaming inserts with GroupIntoBatches
* Moved autosharding option from BigQueryOption to BigQueryIOBuilder; addressed comments.
* fix checkstyle error
* Revert the logic that was dropped during merge
* Add comments for RequiresStableInput
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@nehsyc@pabloem@reuvenlax