From 48c2102ee297cd40fa6f5392546010550bd85bda Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Mon, 6 Oct 2025 12:44:48 -0400 Subject: [PATCH] runtime/vam: fix cast from string to string --- runtime/vam/expr/cast/bytes.go | 10 +++++++--- runtime/ztests/expr/cast/bytes.yaml | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/runtime/vam/expr/cast/bytes.go b/runtime/vam/expr/cast/bytes.go index 3cea7f351..5c6e39a40 100644 --- a/runtime/vam/expr/cast/bytes.go +++ b/runtime/vam/expr/cast/bytes.go @@ -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) } diff --git a/runtime/ztests/expr/cast/bytes.yaml b/runtime/ztests/expr/cast/bytes.yaml index 4d4c6e31b..7ea577413 100644 --- a/runtime/ztests/expr/cast/bytes.yaml +++ b/runtime/ztests/expr/cast/bytes.yaml @@ -3,6 +3,9 @@ spq: this::bytes vector: true input: | + 0x01 + null::bytes + null "foo" "bar"::=named "" @@ -10,6 +13,9 @@ input: | {x:"foo"} output: | + 0x01 + null::bytes + null::bytes 0x666f6f 0x626172 0x