Skip to content

Commit

Permalink
[stats] convert binary to string for stats bound rows
Browse files Browse the repository at this point in the history
  • Loading branch information
max-hoffman committed Sep 16, 2024
1 parent 672b271 commit 910572e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sql/stats/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package stats

import (
"fmt"
"github.com/dolthub/go-mysql-server/sql/types"
"io"
"strings"
"time"
Expand Down Expand Up @@ -134,12 +135,17 @@ func ParseRow(rowStr string, types []sql.Type) (sql.Row, error) {
return row, nil
}

func StringifyKey(r sql.Row, types []sql.Type) string {
func StringifyKey(r sql.Row, typs []sql.Type) string {
b := strings.Builder{}
sep := ""
for i, v := range r {
typ := typs[i]
if _, ok := typ.(sql.StringType); ok {
typ = types.LongText
v, _, _ = typ.Convert(v)
}
if v == nil {
v = types[i].Zero()
v = typ.Zero()
}
fmt.Fprintf(&b, "%s%v", sep, v)
sep = ","
Expand Down

0 comments on commit 910572e

Please sign in to comment.