-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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] Unable to JSON marshal float64 arrays which contain a NaN value #40563
Comments
Hmm, if we do this we'd probably need to also update the corresponding |
@zeroshade @xxgreg I would like to make the above changes. I can assign myself via
|
Hey @verma-kartik, using As for your observations:
While there aren't tests that
The reason why Float16 is separate from those is due to the fact that the code gen has to handle |
take |
@zeroshade Thanks for pointing me in the right direction for tests. |
@zeroshade @xxgreg ...
case math.IsInf(float64(f), 1):
vals[i] = "+Inf"
... Or, use the ...
case math.Float32frombits(0x7F800000) == f:
vals[i] = "+Inf"
... Similarly for handling NaN and -Inf. Which one (or neither) is feasible? For ...
func NegInf() Num { return Num{bits: 0xFC00} }
... |
Personally, I would just use |
…NaN value (#41109) ### Rationale for this change From this [issue](#40563 (comment)). ### What changes are included in this PR? MarshalJSON() is changed for Float32, Float64 to handle NaN, +Inf and -Inf values. I was only able to handle NaN for Float16. UnmarshalJSON() was already handling NaN, +Inf and -Inf in the right way. ### Are these changes tested? These changes are tested. Tests are included in those files where I find it was logically appropriate to do so. ### Are there any user-facing changes? They will be able to handle corner values for Float32, Float64 now. * GitHub Issue: #40563 Lead-authored-by: verma-kartik <[email protected]> Co-authored-by: work-vermakartik <[email protected]> Co-authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
Issue resolved by pull request 41109 |
🎉 Thanks team! @verma-kartik @zeroshade |
…NaN value (#41109) ### Rationale for this change From this [issue](#40563 (comment)). ### What changes are included in this PR? MarshalJSON() is changed for Float32, Float64 to handle NaN, +Inf and -Inf values. I was only able to handle NaN for Float16. UnmarshalJSON() was already handling NaN, +Inf and -Inf in the right way. ### Are these changes tested? These changes are tested. Tests are included in those files where I find it was logically appropriate to do so. ### Are there any user-facing changes? They will be able to handle corner values for Float32, Float64 now. * GitHub Issue: #40563 Lead-authored-by: verma-kartik <[email protected]> Co-authored-by: work-vermakartik <[email protected]> Co-authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
…ain a NaN value (apache#41109) ### Rationale for this change From this [issue](apache#40563 (comment)). ### What changes are included in this PR? MarshalJSON() is changed for Float32, Float64 to handle NaN, +Inf and -Inf values. I was only able to handle NaN for Float16. UnmarshalJSON() was already handling NaN, +Inf and -Inf in the right way. ### Are these changes tested? These changes are tested. Tests are included in those files where I find it was logically appropriate to do so. ### Are there any user-facing changes? They will be able to handle corner values for Float32, Float64 now. * GitHub Issue: apache#40563 Lead-authored-by: verma-kartik <[email protected]> Co-authored-by: work-vermakartik <[email protected]> Co-authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
…ain a NaN value (apache#41109) ### Rationale for this change From this [issue](apache#40563 (comment)). ### What changes are included in this PR? MarshalJSON() is changed for Float32, Float64 to handle NaN, +Inf and -Inf values. I was only able to handle NaN for Float16. UnmarshalJSON() was already handling NaN, +Inf and -Inf in the right way. ### Are these changes tested? These changes are tested. Tests are included in those files where I find it was logically appropriate to do so. ### Are there any user-facing changes? They will be able to handle corner values for Float32, Float64 now. * GitHub Issue: apache#40563 Lead-authored-by: verma-kartik <[email protected]> Co-authored-by: work-vermakartik <[email protected]> Co-authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
…ain a NaN value (apache#41109) ### Rationale for this change From this [issue](apache#40563 (comment)). ### What changes are included in this PR? MarshalJSON() is changed for Float32, Float64 to handle NaN, +Inf and -Inf values. I was only able to handle NaN for Float16. UnmarshalJSON() was already handling NaN, +Inf and -Inf in the right way. ### Are these changes tested? These changes are tested. Tests are included in those files where I find it was logically appropriate to do so. ### Are there any user-facing changes? They will be able to handle corner values for Float32, Float64 now. * GitHub Issue: apache#40563 Lead-authored-by: verma-kartik <[email protected]> Co-authored-by: work-vermakartik <[email protected]> Co-authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
…ain a NaN value (apache#41109) ### Rationale for this change From this [issue](apache#40563 (comment)). ### What changes are included in this PR? MarshalJSON() is changed for Float32, Float64 to handle NaN, +Inf and -Inf values. I was only able to handle NaN for Float16. UnmarshalJSON() was already handling NaN, +Inf and -Inf in the right way. ### Are these changes tested? These changes are tested. Tests are included in those files where I find it was logically appropriate to do so. ### Are there any user-facing changes? They will be able to handle corner values for Float32, Float64 now. * GitHub Issue: apache#40563 Lead-authored-by: verma-kartik <[email protected]> Co-authored-by: work-vermakartik <[email protected]> Co-authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
…ain a NaN value (apache#41109) ### Rationale for this change From this [issue](apache#40563 (comment)). ### What changes are included in this PR? MarshalJSON() is changed for Float32, Float64 to handle NaN, +Inf and -Inf values. I was only able to handle NaN for Float16. UnmarshalJSON() was already handling NaN, +Inf and -Inf in the right way. ### Are these changes tested? These changes are tested. Tests are included in those files where I find it was logically appropriate to do so. ### Are there any user-facing changes? They will be able to handle corner values for Float32, Float64 now. * GitHub Issue: apache#40563 Lead-authored-by: verma-kartik <[email protected]> Co-authored-by: work-vermakartik <[email protected]> Co-authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
…NaN value (#41109) ### Rationale for this change From this [issue](apache/arrow#40563 (comment)). ### What changes are included in this PR? MarshalJSON() is changed for Float32, Float64 to handle NaN, +Inf and -Inf values. I was only able to handle NaN for Float16. UnmarshalJSON() was already handling NaN, +Inf and -Inf in the right way. ### Are these changes tested? These changes are tested. Tests are included in those files where I find it was logically appropriate to do so. ### Are there any user-facing changes? They will be able to handle corner values for Float32, Float64 now. * GitHub Issue: #40563 Lead-authored-by: verma-kartik <[email protected]> Co-authored-by: work-vermakartik <[email protected]> Co-authored-by: Matt Topol <[email protected]> Signed-off-by: Matt Topol <[email protected]>
array.Float64.MarshallJSON()
returns the following error for the example code below:Consider updating the marshalling code for Float64 and other floating point array types with something like:
Component(s)
Go
The text was updated successfully, but these errors were encountered: