Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions runtime/vam/expr/cast/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import (
)

func castToBytes(vec vector.Any, index []uint32) (vector.Any, []uint32, string, bool) {
strVec, ok := vec.(*vector.String)
if !ok {
var out vector.Any
switch vec := vec.(type) {
case *vector.Bytes:
out = vec
case *vector.String:
out = vector.NewBytes(vec.Table(), vector.NullsOf(vec))
default:
return nil, nil, "", false
}
out := vector.Any(vector.NewBytes(strVec.Table(), vector.NullsOf(strVec)))
if index != nil {
out = vector.Pick(out, index)
}
Expand Down
6 changes: 6 additions & 0 deletions runtime/ztests/expr/cast/bytes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ spq: this::bytes
vector: true

input: |
0x01
null::bytes
null
"foo"
"bar"::=named
""
null::string
{x:"foo"}

output: |
0x01
null::bytes
null::bytes
0x666f6f
0x626172
0x
Expand Down