Skip to content

Conversation

@kkdoon
Copy link
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
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
Contributor

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

* <p> This API allows direct deserialization of AVRO data to the target class.
*/
public static <T> TypedRead<T> readWithDatumReader(
AvroSource.DatumReaderFactory<T> factory, org.apache.avro.Schema readerSchema) {
Copy link
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
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
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
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
Contributor

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

@kennknowles
Copy link
Member

R: @chamikaramj

@github-actions
Copy link
Contributor

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

@steveniemitz
Copy link
Contributor

Run Java PreCommit

@steveniemitz
Copy link
Contributor

Run Java PreCommit

@steveniemitz
Copy link
Contributor

Run Java_Examples_Dataflow PreCommit

@steveniemitz
Copy link
Contributor

Run Java_Examples_Dataflow_Java11 PreCommit

@steveniemitz
Copy link
Contributor

Run Java_Examples_Dataflow_Java17 PreCommit

@steveniemitz
Copy link
Contributor

Run Java PreCommit

@steveniemitz
Copy link
Contributor

Run Java PreCommit

@kkdoon
Copy link
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.

@steveniemitz steveniemitz changed the title Support custom avro DatumReader when reading from BigQuery #22717 Support custom avro DatumReader when reading from BigQuery Oct 6, 2022
@steveniemitz steveniemitz merged commit 8bdf357 into apache:master Oct 6, 2022
kkdoon added a commit to twitter-forks/beam that referenced this pull request Oct 6, 2022
)

Co-authored-by: Kanishk Karanawat <kkaranawat@twitter.com>
@ahmedabu98
Copy link
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