This is an automated email from the ASF dual-hosted git repository.

jrmccluskey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 91c4b87aa95 Handle single-precision float values in the standard 
coders tests properly (#22716)
91c4b87aa95 is described below

commit 91c4b87aa95d89aac806ef374fda63637960bd6c
Author: Jack McCluskey <[email protected]>
AuthorDate: Tue Aug 16 09:55:37 2022 -0400

    Handle single-precision float values in the standard coders tests properly 
(#22716)
---
 sdks/go/test/regression/coders/fromyaml/fromyaml.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sdks/go/test/regression/coders/fromyaml/fromyaml.go 
b/sdks/go/test/regression/coders/fromyaml/fromyaml.go
index 417f801c615..4ea210c7ee8 100644
--- a/sdks/go/test/regression/coders/fromyaml/fromyaml.go
+++ b/sdks/go/test/regression/coders/fromyaml/fromyaml.go
@@ -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.
@@ -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{}) {
@@ -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 {

Reply via email to