Skip to content

Commit 4479e84

Browse files
author
James Cor
committed
asdf
1 parent 04c6718 commit 4479e84

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

sql/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func HashOf(ctx context.Context, sch Schema, v Row) (uint64, error) {
4040

4141
if i < len(sch) {
4242
typ := sch[i].Type
43-
if strType, ok := typ.(StringType); ok {
43+
if strType, ok := typ.(StringType); ok && x != nil {
4444
newX, _, err := strType.Convert(ctx, x)
4545
if err != nil {
4646
return 0, err

sql/plan/subquery.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,7 @@ func (s *Subquery) HasResultRow(ctx *sql.Context, row sql.Row) (bool, error) {
470470

471471
// normalizeValue returns a canonical version of a value for use in a sql.KeyValueCache.
472472
// Two values that compare equal should have the same canonical version.
473-
// TODO: Fix https://github.com/dolthub/dolt/issues/9049 by making this function collation-aware
474-
func normalizeForKeyValueCache(ctx *sql.Context, typ sql.Type, val interface{}) (interface{}, error) {
473+
func normalizeForKeyValueCache(ctx *sql.Context, val interface{}) (interface{}, error) {
475474
val, err := sql.UnwrapAny(ctx, val)
476475
if err != nil {
477476
return nil, err
@@ -480,8 +479,8 @@ func normalizeForKeyValueCache(ctx *sql.Context, typ sql.Type, val interface{})
480479
}
481480

482481
func putAllRows(ctx *sql.Context, cache sql.KeyValueCache, sch sql.Schema, vals []interface{}) error {
483-
for i, val := range vals {
484-
normVal, err := normalizeForKeyValueCache(ctx, sch[i].Type, val)
482+
for _, val := range vals {
483+
normVal, err := normalizeForKeyValueCache(ctx, val)
485484
if err != nil {
486485
return err
487486
}

sql/rowexec/agg.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,22 +250,21 @@ func groupingKey(
250250
return 0, err
251251
}
252252

253+
// TODO: this should just use sql.HashOf
254+
253255
if i > 0 {
254256
// separate each expression in the grouping key with a nil byte
255257
if _, err = hash.Write([]byte{0}); err != nil {
256258
return 0, err
257259
}
258260
}
259261

260-
extendedType, isExtendedType := expr.Type().(types.ExtendedType)
261-
stringType, isStringType := expr.Type().(sql.StringType)
262-
263-
if isExtendedType && v != nil {
262+
if extendedType, isExtendedType := expr.Type().(types.ExtendedType); isExtendedType && v != nil {
264263
bytes, err := extendedType.SerializeValue(ctx, v)
265264
if err == nil {
266265
_, err = fmt.Fprint(hash, string(bytes))
267266
}
268-
} else if isStringType && v != nil {
267+
} else if stringType, isStringType := expr.Type().(sql.StringType); isStringType && v != nil {
269268
v, err = types.ConvertToString(ctx, v, stringType, nil)
270269
if err == nil {
271270
err = stringType.Collation().WriteWeightString(hash, v.(string))

0 commit comments

Comments
 (0)