damccorm commented on a change in pull request #16923:
URL: https://github.com/apache/beam/pull/16923#discussion_r827178434
##########
File path: sdks/go/test/regression/coders/fromyaml/fromyaml.go
##########
@@ -218,6 +218,19 @@ func diff(c Coder, elem *exec.FullValue, eg yaml.MapItem)
bool {
}
return pass
+ case "beam:coder:nullable:v1":
+ if elem.Elm == nil || eg.Value == nil {
+ got, want = elem.Elm, eg.Value
+ } else {
+ got = string(elem.Elm.([]byte))
Review comment:
A couple thoughts on this test:
1) If `elem.Elm` can't be cast to `[]byte` this will blow up. It would
probably be better to guard this with something like:
```
gotBytes, ok := elem.Elm.([]byte)
if !ok {
log.Printf("elem.Elm - want type []byte, got %v of type", elem.Elm,
elem.Elm.(type)
}
got = string(gotBytes)
```
2) Its odd to me that we're ok receiving `egv` as either a string or a
[]byte - shouldn't this be deterministic? In this case, I think I would expect
it to be of type []byte.
3) If eg.Value isn't of type string or []byte, this switch won't do anything
and got will be an empty interface{}. We should add a default case that errors
directly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]