SQL Expressions: Replace NaN/Inf values with Null (#112641)

This is because MySQL doesn't support storing of NaN valuels, and therefore go-mysql-server isn't going to either.

Float fields/columns are always mapped to be nullable now, otherwise we would have to replace NaN/Inf with 0.
This commit is contained in:
Kyle Brandt
2025-10-21 10:43:04 -04:00
committed by GitHub
parent 5d8492d728
commit e930b3e6c4
4 changed files with 100 additions and 7 deletions
+11
View File
@@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"io"
"math"
"strings"
mysql "github.com/dolthub/go-mysql-server/sql"
@@ -92,6 +93,16 @@ func (ri *rowIter) Next(ctx *mysql.Context) (mysql.Row, error) {
continue
}
val, _ := field.ConcreteAt(ri.row)
switch v := val.(type) {
case float32:
if math.IsNaN(float64(v)) || math.IsInf(float64(v), 0) {
continue
}
case float64:
if math.IsNaN(v) || math.IsInf(v, 0) {
continue
}
}
// If the field is JSON, convert json.RawMessage to types.JSONDocument
if raw, ok := val.(json.RawMessage); ok {