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

[BEAM-12913] Enable configuration of query priority in ReadFromBigQuery #15536

Merged
merged 3 commits into from
Sep 23, 2021

Conversation

chunyang
Copy link
Contributor

@chunyang chunyang commented Sep 18, 2021

Changes:

  • Make ReadFromBigQuery submit queries with BATCH priority by default. This mirrors the default behavior in the Java BigQueryIO and the legacy native Dataflow IO.
  • Add a query_priority parameter to ReadFromBigQuery to allow toggling between INTERACTIVE and BATCH priority. Add a corresponding BigQueryQueryPriority object to hold the priority constants.

Submitting BigQuery queries with BATCH priority allows queries to be started when idle resources are available and allows queries submitted from Beam to not count toward a project's concurrent rate limit.


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.

ValidatesRunner compliance status (on master branch)

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- Build Status Build Status Build Status Build Status ---
Java Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Python --- Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status ---
XLang Build Status Build Status Build Status Build Status Build Status ---

Examples testing status on various runners

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- --- --- --- --- --- ---
Java --- Build Status
Build Status
Build Status
--- --- --- --- ---
Python --- --- --- --- --- --- ---
XLang --- --- --- --- --- --- ---

Post-Commit SDK/Transform Integration Tests Status (on master branch)

Go Java Python
Build Status Build Status Build Status
Build Status
Build Status

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website Whitespace Typescript
Non-portable Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status Build Status Build Status
Portable --- Build Status 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.

@chunyang
Copy link
Contributor Author

R: @pabloem

@codecov
Copy link

codecov bot commented Sep 21, 2021

Codecov Report

Merging #15536 (59b0fb9) into master (afccd52) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15536      +/-   ##
==========================================
- Coverage   83.78%   83.77%   -0.01%     
==========================================
  Files         444      444              
  Lines       60189    60273      +84     
==========================================
+ Hits        50427    50493      +66     
- Misses       9762     9780      +18     
Impacted Files Coverage Δ
sdks/python/apache_beam/io/gcp/bigquery.py 75.68% <100.00%> (+0.14%) ⬆️
sdks/python/apache_beam/io/gcp/bigquery_tools.py 86.71% <100.00%> (+0.03%) ⬆️
...ks/python/apache_beam/runners/interactive/utils.py 92.30% <0.00%> (-3.30%) ⬇️
sdks/python/apache_beam/io/source_test_utils.py 88.47% <0.00%> (-1.39%) ⬇️
sdks/python/apache_beam/internal/metrics/metric.py 90.42% <0.00%> (-1.07%) ⬇️
sdks/python/apache_beam/testing/util.py 96.71% <0.00%> (-0.44%) ⬇️
...hon/apache_beam/runners/worker/bundle_processor.py 93.26% <0.00%> (-0.25%) ⬇️
sdks/python/apache_beam/portability/common_urns.py 100.00% <0.00%> (ø)
sdks/python/apache_beam/runners/common.py 88.87% <0.00%> (+0.14%) ⬆️
sdks/python/apache_beam/transforms/external.py 77.70% <0.00%> (+3.30%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update afccd52...59b0fb9. Read the comment docs.

@@ -1915,6 +1927,11 @@ class ReadFromBigQuery(PTransform):
that dataset, and will remove it once it is not needed. Job needs access
to create and delete tables within the given dataset. Dataset name
should *not* start with the reserved prefix `beam_temp_dataset_`.
query_priority (BigQueryQueryPriority): By default, this transform runs
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering can we make a batch priority by default in ReadFromBigQuery? What would be the use case for the user to make it interactive? I just want to make sure that the parameter that got exposed are really necessary for the end user and it confirms with style guide

https://beam.apache.org/contribute/ptransform-style-guide/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR does make the priority BATCH by default.

If you're asking about whether or not we should expose a query_priority parameter, I don't have strong opinions either way. My original commit (b66e4b1) makes it non-configurable, but after seeing that it's configurable in the Java BigQueryIO, I decided to make the Python side consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

never mind, my comment. I was thinking initially that the user doesn't need to be aware of this parameter. There's no point executing the query if there's not enough resources. Thus, batch priority for dataflow job makes better sense.

Copy link
Member

Choose a reason for hiding this comment

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

thanks for checking all of these - I was not sure about adding the extra parameter, bu since Java exposes it, I think it makes sense for it to be exposed by Python as well.

Copy link
Member

@pabloem pabloem left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -1915,6 +1927,11 @@ class ReadFromBigQuery(PTransform):
that dataset, and will remove it once it is not needed. Job needs access
to create and delete tables within the given dataset. Dataset name
should *not* start with the reserved prefix `beam_temp_dataset_`.
query_priority (BigQueryQueryPriority): By default, this transform runs
Copy link
Member

Choose a reason for hiding this comment

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

thanks for checking all of these - I was not sure about adding the extra parameter, bu since Java exposes it, I think it makes sense for it to be exposed by Python as well.

@pabloem pabloem merged commit 84c082d into apache:master Sep 23, 2021
@y1chi
Copy link
Contributor

y1chi commented Sep 24, 2021

It looks like this PR is causing python postcommit to fail: https://ci-beam.apache.org/job/beam_PostCommit_Python37/4309/

@chunyang Could you PTAL.

@chunyang chunyang deleted the cyang/rfbq-batch branch September 24, 2021 17:55
@chunyang
Copy link
Contributor Author

@y1chi yes I just saw that, will put together a fix right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants