Skip to content

Commit

Permalink
update serial parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
muroon committed Aug 2, 2021
1 parent afc9703 commit 4b670e7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/aws/aws-sdk-go/service/athena"
"github.com/aws/aws-sdk-go/service/athena/athenaiface"
"github.com/prestodb/presto-go-client/presto"
"strconv"
"strings"
"time"
)
Expand Down Expand Up @@ -101,7 +102,7 @@ func (s *stmtAthena) makeQuery(args []interface{}) (string, error) {
params := make([]string, 0, len(args))
for _, arg := range args {
var param string
param, err := presto.Serial(arg)
param, err := serial(arg)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -241,3 +242,13 @@ func (s *stmtAthena) waitOnQuery(ctx context.Context, queryID string) error {
}
}
}

func serial(v interface{}) (string, error) {
if x, ok := v.(string); ok {
if _, err := strconv.ParseFloat(string(x), 64); err == nil {
return presto.Serial(presto.Numeric(x))
}
}

return presto.Serial(v)
}

0 comments on commit 4b670e7

Please sign in to comment.