Skip to content

Support custom avro DatumReader when reading from BigQuery#22718

Merged
steveniemitz merged 21 commits intoapache:masterfrom
twitter-forks:bq-datumreader
Oct 6, 2022
Merged

Support custom avro DatumReader when reading from BigQuery#22718
steveniemitz merged 21 commits intoapache:masterfrom
twitter-forks:bq-datumreader

Conversation

@kkdoon
Copy link
Copy Markdown
Contributor

@kkdoon kkdoon commented Aug 13, 2022

Similar to 11479 this PR adds functionality to directly deserialize Avro records to the target class, via the user specified DatumReader, in BigQueryIO.

R: @pabloem @chamikaramj @steveniemitz

This fixes #22717


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).
  • 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.

@github-actions
Copy link
Copy Markdown
Contributor

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @kennknowles for label java.
R: @chamikaramj for label io.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@steveniemitz
Copy link
Copy Markdown
Contributor

can we plumb this down into BigQueryStorageAvroReader as well so it'll work with direct reads?

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.

can we make the reader schema optional, and use the writer schema if its not set? Thats how AvroIO works IIRC.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems like AvroIO derives it in case the class is of SpecificData subType. We could do the same but we would need to take the class type as input instead (don't think its cleaner though).

Also, readerSchema is needed by AvroSource in general, as it does validation based on that, if parserFn is not set,
as well as derives the AvroCoder based on the readerSchema. Since it gets the writer schema during runtime from the file metadata, we cannot assign reader schema as writer schema on the submitter side.

@kkdoon
Copy link
Copy Markdown
Contributor Author

kkdoon commented Aug 16, 2022

BigQueryStorageAvroReader

yeah, i was thinking of tackling that in another review. I could add in this one too to allow this for different read types.

@steveniemitz
Copy link
Copy Markdown
Contributor

BigQueryStorageAvroReader

yeah, i was thinking of tackling that in another review. I could add in this one too to allow this for different read types.

that's cool, you can do it in another review, just curious.

@github-actions
Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @kennknowles @chamikaramj

@kennknowles
Copy link
Copy Markdown
Member

R: @chamikaramj

@github-actions
Copy link
Copy Markdown
Contributor

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

Kanishk Karanawat added 4 commits September 29, 2022 00:53
This reverts commit 80da4eff8bf674f3f27eee5733a9ec714dba1746.
@kkdoon kkdoon reopened this Sep 29, 2022
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 29, 2022

Codecov Report

Merging #22718 (1342a7f) into master (b59df6c) will increase coverage by 9.95%.
The diff coverage is n/a.

❗ Current head 1342a7f differs from pull request most recent head ec1ce6d. Consider uploading reports for the commit ec1ce6d to get more accurate results

@@            Coverage Diff             @@
##           master   #22718      +/-   ##
==========================================
+ Coverage   73.44%   83.40%   +9.95%     
==========================================
  Files         718      480     -238     
  Lines       95680    66483   -29197     
==========================================
- Hits        70273    55447   -14826     
+ Misses      24096    11036   -13060     
+ Partials     1311        0    -1311     
Flag Coverage Δ
go ?
python 83.40% <ø> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ython/apache_beam/io/gcp/experimental/spannerio.py 82.15% <0.00%> (-4.79%) ⬇️
.../python/apache_beam/testing/test_stream_service.py 88.09% <0.00%> (-4.77%) ⬇️
...ks/python/apache_beam/runners/worker/statecache.py 89.69% <0.00%> (-2.18%) ⬇️
...che_beam/runners/interactive/interactive_runner.py 90.06% <0.00%> (-1.71%) ⬇️
...python/apache_beam/runners/worker/worker_status.py 75.33% <0.00%> (-1.34%) ⬇️
...ache_beam/runners/interactive/pipeline_fragment.py 98.33% <0.00%> (-0.86%) ⬇️
sdks/python/apache_beam/io/localfilesystem.py 90.97% <0.00%> (-0.76%) ⬇️
...eam/runners/portability/fn_api_runner/execution.py 92.44% <0.00%> (-0.65%) ⬇️
...hon/apache_beam/runners/worker/bundle_processor.py 93.17% <0.00%> (-0.38%) ⬇️
sdks/python/apache_beam/ml/inference/base.py 95.58% <0.00%> (-0.26%) ⬇️
... and 251 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@steveniemitz
Copy link
Copy Markdown
Contributor

Run Java PreCommit

@steveniemitz
Copy link
Copy Markdown
Contributor

Run Java PreCommit

@steveniemitz
Copy link
Copy Markdown
Contributor

Run Java_Examples_Dataflow PreCommit

@steveniemitz
Copy link
Copy Markdown
Contributor

Run Java_Examples_Dataflow_Java11 PreCommit

@steveniemitz
Copy link
Copy Markdown
Contributor

Run Java_Examples_Dataflow_Java17 PreCommit

@steveniemitz
Copy link
Copy Markdown
Contributor

Run Java PreCommit

@steveniemitz
Copy link
Copy Markdown
Contributor

Run Java PreCommit

@kkdoon
Copy link
Copy Markdown
Contributor Author

kkdoon commented Oct 6, 2022

I ran and profiled a few dataflow jobs with and without my changes to test for performance regression. Overall the profiling data looks good for these new changes.

@ahmedabu98
Copy link
Copy Markdown
Contributor

I believe this PR broke Java Dataflow PostCommits: https://ci-beam.apache.org/job/beam_PostCommit_Java_DataflowV1/2173/testReport/. See #23541

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]: Support custom avro DatumReader when reading from BigQuery

4 participants