beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (BEAM-2989) Improve coder inference for WithKeys.of(null)
Date Fri, 29 Sep 2017 21:20:02 GMT


ASF GitHub Bot commented on BEAM-2989:

GitHub user youngoli opened a pull request:

    [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](
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
    `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 bug-2989

Alternatively you can review and apply these changes as the patch at:

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 <>
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:
>             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|]
but using a Void key type should pass coder inference.

This message was sent by Atlassian JIRA

View raw message