[
https://issues.apache.org/jira/browse/BEAM-2989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16186436#comment-16186436
]
ASF GitHub Bot commented on BEAM-2989:
--------------------------------------
GitHub user youngoli opened a pull request:
https://github.com/apache/beam/pull/3922
[BEAM-2989] Fixed error when using Void type in WithKeys.
Follow this checklist to help us incorporate your contribution quickly and
easily:
- [x] Make sure there is a [JIRA
issue](https://issues.apache.org/jira/projects/BEAM/issues/) filed for the
change (usually before you start working on it). Trivial changes like typos do
not require a JIRA issue. Your pull request should address just this issue,
without pulling in other changes.
- [x] Each commit in the pull request should have a meaningful subject
line and body.
- [x] Format the pull request title like `[BEAM-XXX] Fixes bug in
ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA
issue.
- [x] Write a pull request description that is detailed enough to
understand what the pull request does, how, and why.
- [x] Run `mvn clean verify` to make sure basic checks pass. A more
thorough check will be performed on your pull request automatically.
- [ ] If this contribution is large, please file an Apache [Individual
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
---
`WithKeys` had trouble correctly getting a `VoidCoder` when called with a
null input before. This fix makes it so that it now functions when the input is
`(Void) null`. This is done by passing Void.class as the key's class type
instead of null, if the inputted key was null. Note that a null input that
isn't cast to Void calls the `WithKeys.of` taking a `SerializableFunction`
instead, so I added a precondition with a warning message to that one.
Also added a unit test to confirm that the fix works as intended, a quick
change to `VoidCoder` to ensure that it doesn't get used inappropriately, and
fixed a few warnings in `WithKeysTest`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/youngoli/beam bug-2989
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/beam/pull/3922.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #3922
----
commit 97fa1f0e10f0cdfb4c6dff54e39230da41478d19
Author: Daniel Oliveira <[email protected]>
Date: 2017-09-29T21:10:00Z
[BEAM-2989] Fixed error when using Void type in WithKeys.
Also added error messages to WithKeys.of and VoidCoder.encode.
----
> Improve coder inference for WithKeys.of(null)
> ---------------------------------------------
>
> Key: BEAM-2989
> URL: https://issues.apache.org/jira/browse/BEAM-2989
> Project: Beam
> Issue Type: Improvement
> Components: sdk-java-core
> Reporter: Luke Cwik
> Assignee: Daniel Oliveira
> Priority: Minor
>
> WithKeys.<Void, String>of((Void) null)) should choose a VoidCoder as the key
> coder instead of erroring out.
> {code:java}
> java.lang.IllegalStateException: Unable to return a default Coder for
> <transform> [PCollection]. Correct one of the following root causes:
> No Coder has been manually specified; you may do so using .setCoder().
> Inferring a Coder from the CoderRegistry failed: Cannot provide coder for
> parameterized type org.apache.beam.sdk.values.KV<K, V>: Unable to provide a
> Coder for K.
> {code}
> [WithKeysTest#testConstantKeys|https://github.com/apache/beam/blob/352f106f992a2ff4c08274685657242f04f967ef/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/WithKeysTest.java#L87]
> but using a Void key type should pass coder inference.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)