beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Work logged] (BEAM-5376) Row interface doesn't support nullability on all fields.
Date Thu, 13 Sep 2018 17:39:00 GMT


ASF GitHub Bot logged work on BEAM-5376:

                Author: ASF GitHub Bot
            Created on: 13/Sep/18 17:38
            Start Date: 13/Sep/18 17:38
    Worklog Time Spent: 10m 
      Work Description: amaliujia commented on a change in pull request #6383: [BEAM-5376]
Support nullability on all Row types

 File path: sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/
 @@ -155,10 +155,10 @@ public void testRecursiveGetters() throws NoSuchSchemaException {
     Row nestedRow = row.getRow("nested");
     assertEquals("string", nestedRow.getString("str"));
-    assertEquals((byte) 1, nestedRow.getByte("aByte"));
-    assertEquals((short) 2, nestedRow.getInt16("aShort"));
-    assertEquals((int) 3, nestedRow.getInt32("anInt"));
-    assertEquals((long) 4, nestedRow.getInt64("aLong"));
+    assertEquals((byte) 1, (Object) nestedRow.getByte("aByte"));
 Review comment:
   My intention was to make the code more understandable for readers. Because if we do explicitly
casting and leave less guess room for readers, readers will know the same type of values are
compared, and they do not need to question the correctness because of implicitly casting somewhere.
At least, readers do not need to search  how `assertEquals` is implemented for different types.
From this perspective, `assertEquals(Byte.valueof((byte) 1), nestedRow.getByte("aByte"))`
is ugly, but necessary.
   After I read the code, seems like the family of `assertEquals` in JUnit is simpler. `assertEquals(Byte.valueof((byte)
1), nestedRow.getByte("aByte"))` will be converted to `assertEquals(object, object)`, and
`object.equals(object)` will be called. In `Byte` implementation, as Anton pointed out, `Byte.equals()`
accepts `Object` and does a casting anyway. So from implementation perspective, there is no
difference among approaches in this discussion.
   Since there isn't a perfect way to make the code clear, I am ok with either the original
way in this PR, or other discussed way to implement it.

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

Issue Time Tracking

    Worklog Id:     (was: 144027)
    Time Spent: 2h 20m  (was: 2h 10m)

> Row interface doesn't support nullability on all fields.
> --------------------------------------------------------
>                 Key: BEAM-5376
>                 URL:
>             Project: Beam
>          Issue Type: Improvement
>          Components: dsl-sql
>            Reporter: Andrew Pilloud
>            Assignee: Andrew Pilloud
>            Priority: Major
>          Time Spent: 2h 20m
>  Remaining Estimate: 0h
> For example: 
> {code:java}
> public boolean getBoolean(int idx);{code}
> Should be:
> {code:java}
> public Boolean getBoolean(int idx);{code}

This message was sent by Atlassian JIRA

View raw message