Skip to content

Commit

Permalink
Runtime: Parse inf and NaN results from Druid as floats (#4831)
Browse files Browse the repository at this point in the history
  • Loading branch information
begelundmuller committed May 6, 2024
1 parent 97f6eae commit 8f3ff05
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions runtime/drivers/druid/druidsqldriver/druid_api_sql_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"net/http"
"reflect"
"strconv"
"time"

"github.com/google/uuid"
Expand Down Expand Up @@ -135,6 +136,44 @@ func (c *sqlConnection) QueryContext(ctx context.Context, query string, args []d
return v, nil
}
}
case "FLOAT":
transformers[i] = func(v any) (any, error) {
switch v := v.(type) {
case float64:
return float32(v), nil
case string:
return strconv.ParseFloat(v, 32)
default:
return v, nil
}
}
case "DOUBLE":
transformers[i] = func(v any) (any, error) {
switch v := v.(type) {
case string:
return strconv.ParseFloat(v, 64)
default:
return v, nil
}
}
case "REAL":
transformers[i] = func(v any) (any, error) {
switch v := v.(type) {
case string:
return strconv.ParseFloat(v, 64)
default:
return v, nil
}
}
case "DECIMAL":
transformers[i] = func(v any) (any, error) {
switch v := v.(type) {
case string:
return strconv.ParseFloat(v, 64)
default:
return v, nil
}
}
case "TIMESTAMP":
transformers[i] = func(v any) (any, error) {
t, err := time.Parse(time.RFC3339, v.(string))
Expand Down

1 comment on commit 8f3ff05

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Published on https://ui.rilldata.com as production
🚀 Deployed on https://6638e2bc412073e166b094fa--rill-ui.netlify.app

Please sign in to comment.