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

Skipping floats that cannot be marshalled #5163

Merged
merged 12 commits into from Apr 14, 2020
6 changes: 6 additions & 0 deletions query/outputnode.go
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"math"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -251,6 +252,11 @@ func valToBytes(v types.Val) ([]byte, error) {
return []byte(fmt.Sprintf("%d", v.Value)), nil
}
case types.FloatID:
// +Inf, -Inf and NaN are not representable in JSON.
// Please see https://golang.org/src/encoding/json/encode.go?s=6458:6501#L573
if math.IsInf(v.Value.(float64), 0) || math.IsNaN(v.Value.(float64)) {
return nil, errors.New("Unsupported Inf or NaN in float field")
}
return []byte(fmt.Sprintf("%f", v.Value)), nil
case types.BoolID:
if v.Value.(bool) {
Expand Down