From 62d0639bdf0fa915ca7dc1965abbc46a826e1e5b Mon Sep 17 00:00:00 2001 From: Matthew Nibecker Date: Mon, 25 Nov 2024 12:29:15 -0500 Subject: [PATCH] Fix strftime on views (#5498) Closes #5473, #5469 --- 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