Skip to content

[BEAM-2303] Support SpecificData in AvroCoder - #14410

Merged
iemejia merged 1 commit into
apache:masterfrom
Amar3tto:BEAM-2303
Apr 12, 2021
Merged

[BEAM-2303] Support SpecificData in AvroCoder#14410
iemejia merged 1 commit into
apache:masterfrom
Amar3tto:BEAM-2303

Conversation

@Amar3tto

Copy link
Copy Markdown
Collaborator

Added SpecificDatumReader and SpecificDatumWriter initialization in AvroCoder constructor.


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)

LangSDKULRDataflowFlinkSamzaSparkTwister2
Go------Build Status---Build Status---
JavaBuild StatusBuild StatusBuild Status
Build Status
Build Status
Build Status
Build 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 Status---Build StatusBuild Status---Build Status---

Pre-Commit Tests Status (on master branch)

---JavaPythonGoWebsiteWhitespaceTypescript
Non-portableBuild Status
Build 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.

@Amar3tto

Copy link
Copy Markdown
CollaboratorAuthor

Run Java PreCommit

@KhaninArturKhaninArtur left a comment

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.

LGTM - seems pretty straight forward 🙂

@pabloem

Copy link
Copy Markdown
Member

@Amar3tto@KhaninArtur I guess this is ready to be reviewed by a committer?

@KhaninArtur

Copy link
Copy Markdown
Contributor

@Amar3tto@KhaninArtur I guess this is ready to be reviewed by a committer?

@pabloem, you're right, it's ready

@pabloem

Copy link
Copy Markdown
Member

r: @iemejia@amaliujia

@pabloem
pabloem requested review from amaliujia and iemejiaApril 8, 2021 17:58
@pabloem

Copy link
Copy Markdown
Member

@Amar3tto can you open the PR to not be a draft PR anymore?

@Amar3tto
Amar3tto marked this pull request as ready for review April 8, 2021 18:52
@iemejia

Copy link
Copy Markdown
Member

CC @RyanSkraba mind to take a look at this one since you know SpecificData pretty well

@RyanSkrabaRyanSkraba left a comment

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.

LGTM, thanks for including me in the review!

myCoder.getSchema(), myCoder.getSchema(), myCoder.reflectData.get());
if (myCoder.getType().equals(GenericRecord.class)) {
return new GenericDatumReader<>(myCoder.getSchema());
} else if (SpecificRecord.class.isAssignableFrom(myCoder.getType())) {

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.

This is fun: if the AvroCoder is instantiated as AvroCoder<MySpecificRecord> it will behave differently than AvroCoder<GenericRecord>, even though MySpecificRecord is a GenericRecord. I can see this being a gotcha for some developers, but I think it's the right thing to do and I don't see an alternative.

@iemejiaiemejia left a comment

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.

LGTM

I am really curious in the consequence of this (becuase of @RyanSkraba comment) when mapping from Avro <-> Beam Row. The PR seems right so we can merge it. In case that you can do a follow up testing conversions from SpecificData I will be glad to see how it behaves.

@iemejia
iemejia merged commit b908f59 into apache:masterApr 12, 2021
@clairemcginty

clairemcginty commented Jul 15, 2021

Copy link
Copy Markdown
Contributor

Hi @iemejia / @pabloem / @Amar3tto . this PR created some hidden bugs for us upgrading from Beam 2.29.0 to 2.30.0. It changes the default CharSequence representation in decoded Avro string fields. When using ReflectDatum{Reader,Writer}, CharSequences are backed by default by Strings [1]. This switch to SpecificDatum{Reader,Writer} means that, unless the Avro field property java-class is set to java.lang.String for all String fields, the CharSequences are backed by default now by org.apache.avro.util.Utf8s [2]. a lot of our users were relying on the default representation being Strings and are now seeing runtime errors in pipelines. Finally, Utf8s aren't serializable so there's no default Coder implementation for them, so users would have to convert them to Java strings anyway if they wanted to do a GBK operation on an Avro field, for example. I created a quick Gist to demonstrate the problem: [3].

Is this something I could bring to the ***@ or ****@ mailing list? Let me know what you think.

@lukecwik

lukecwik commented Jul 15, 2021 via email

Copy link
Copy Markdown
Member

Sign up for freeto 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.

7 participants

@Amar3tto@pabloem@KhaninArtur@iemejia@clairemcginty@lukecwik@RyanSkraba