Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Go SDK]: Handle single-precision float values in the standard coders tests #22716

Merged
merged 1 commit into from
Aug 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sdks/go/test/regression/coders/fromyaml/fromyaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ var unimplementedCoders = map[string]bool{
var filteredCases = []struct{ filter, reason string }{
{"logical", "BEAM-9615: Support logical types"},
{"30ea5a25-dcd8-4cdb-abeb-5332d15ab4b9", "https://github.com/apache/beam/issues/21206: Support encoding position."},
{"8c97b6c5-69e5-4733-907b-26cd8edae612", "https://github.com/apache/beam/issues/22629: Support single-precision float."},
}

// Coder is a representation a serialized beam coder.
Expand Down Expand Up @@ -339,6 +338,7 @@ var nameToType = map[string]reflect.Type{
"f_bool": reflectx.Bool,
"f_bytes": reflect.PtrTo(reflectx.ByteSlice),
"f_map": reflect.MapOf(reflectx.String, reflect.PtrTo(reflectx.Int64)),
"f_float": reflectx.Float32,
}

func setField(rv reflect.Value, i int, v interface{}) {
Expand All @@ -356,6 +356,12 @@ func setField(rv reflect.Value, i int, v interface{}) {
rf.SetString(v.(string))
case reflect.Int32:
rf.SetInt(int64(v.(int)))
case reflect.Float32:
c, err := strconv.ParseFloat(v.(string), 32)
if err != nil {
panic(err)
}
rf.SetFloat(c)
case reflect.Float64:
c, err := strconv.ParseFloat(v.(string), 64)
if err != nil {
Expand Down