Skip to content

Commit 525853d

Browse files
authored
runtime/vam: fix cast from string to string (#6281)
1 parent 8e94fe7 commit 525853d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

runtime/vam/expr/cast/bytes.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ import (
55
)
66

77
func castToBytes(vec vector.Any, index []uint32) (vector.Any, []uint32, string, bool) {
8-
strVec, ok := vec.(*vector.String)
9-
if !ok {
8+
var out vector.Any
9+
switch vec := vec.(type) {
10+
case *vector.Bytes:
11+
out = vec
12+
case *vector.String:
13+
out = vector.NewBytes(vec.Table(), vector.NullsOf(vec))
14+
default:
1015
return nil, nil, "", false
1116
}
12-
out := vector.Any(vector.NewBytes(strVec.Table(), vector.NullsOf(strVec)))
1317
if index != nil {
1418
out = vector.Pick(out, index)
1519
}

runtime/ztests/expr/cast/bytes.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ spq: this::bytes
33
vector: true
44

55
input: |
6+
0x01
7+
null::bytes
8+
null
69
"foo"
710
"bar"::=named
811
""
912
null::string
1013
{x:"foo"}
1114
1215
output: |
16+
0x01
17+
null::bytes
18+
null::bytes
1319
0x666f6f
1420
0x626172
1521
0x

0 commit comments

Comments
 (0)