From f9c37a00ce050462ced3c5f55e2407669d6cfb70 Mon Sep 17 00:00:00 2001 From: Matthew Nibecker Date: Fri, 22 Nov 2024 23:03:38 -0500 Subject: [PATCH] Fix strftime on views Closes #5473 --- runtime/vam/expr/function/time.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/runtime/vam/expr/function/time.go b/runtime/vam/expr/function/time.go index 9fa969daed..3ef5ff6b32 100644 --- a/runtime/vam/expr/function/time.go +++ b/runtime/vam/expr/function/time.go @@ -136,13 +136,17 @@ func (s *Strftime) fastPath(fvec *vector.Const, tvec vector.Any) vector.Any { } func (s *Strftime) fastPathLoop(f *strftime.Strftime, vec *vector.Int, index []uint32) *vector.String { + if index != nil { + out := vector.NewStringEmpty(uint32(len(index)), vector.NewBoolView(vec.Nulls, index)) + for _, i := range index { + s := f.FormatString(nano.Ts(vec.Values[i]).Time()) + out.Append(s) + } + return out + } out := vector.NewStringEmpty(vec.Len(), vec.Nulls) for i := range vec.Len() { - idx := i - if index != nil { - idx = index[i] - } - s := f.FormatString(nano.Ts(vec.Values[idx]).Time()) + s := f.FormatString(nano.Ts(vec.Values[i]).Time()) out.Append(s) } return out