This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-go.git


The following commit(s) were added to refs/heads/main by this push:
     new 56b794f  fix(arrow/compute): fix scenario where prealloc output is 
missed (#167)
56b794f is described below

commit 56b794f52a9bfb45fb54a4e070002a69b38fb018
Author: Matt Topol <[email protected]>
AuthorDate: Tue Oct 22 14:44:25 2024 -0400

    fix(arrow/compute): fix scenario where prealloc output is missed (#167)
    
    Fixes #52
---
 arrow/compute/cast_test.go |  7 +++++++
 arrow/compute/executor.go  | 13 ++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/arrow/compute/cast_test.go b/arrow/compute/cast_test.go
index 700d6df..4e5f0a5 100644
--- a/arrow/compute/cast_test.go
+++ b/arrow/compute/cast_test.go
@@ -1622,6 +1622,13 @@ func (c *CastSuite) checkCastZeroCopy(from 
arrow.DataType, json string, to arrow
        checkCastZeroCopy(c.T(), arr, to, compute.NewCastOptions(to, true))
 }
 
+func (c *CastSuite) TestTimestampToTimestampSimpleTimezone() {
+       c.checkCast(&arrow.TimestampType{Unit: arrow.Microsecond, TimeZone: 
"Etc/UTC"},
+               arrow.FixedWidthTypes.Timestamp_us,
+               `["2023-01-01T19:25:00.123456+00:00", null, 
"2023-01-01T19:25:00.123456+00:00"]`,
+               `["2023-01-01T19:25:00.123456+00:00", null, 
"2023-01-01T19:25:00.123456+00:00"]`)
+}
+
 func (c *CastSuite) TestTimestampToTimestamp() {
        tests := []struct {
                coarse, fine arrow.DataType
diff --git a/arrow/compute/executor.go b/arrow/compute/executor.go
index 1374095..54c65ad 100644
--- a/arrow/compute/executor.go
+++ b/arrow/compute/executor.go
@@ -587,8 +587,7 @@ func (s *scalarExecutor) executeSpans(data chan<- Datum) 
(err error) {
 
        if s.preallocContiguous {
                // make one big output alloc
-               prealloc := s.prepareOutput(int(s.iterLen))
-               output = *prealloc
+               output := s.prepareOutput(int(s.iterLen))
 
                output.Offset = 0
                var resultOffset int64
@@ -598,15 +597,19 @@ func (s *scalarExecutor) executeSpans(data chan<- Datum) 
(err error) {
                                break
                        }
                        output.SetSlice(resultOffset, input.Len)
-                       err = s.executeSingleSpan(&input, &output)
+                       err = s.executeSingleSpan(&input, output)
                        resultOffset = nextOffset
                }
                if err != nil {
-                       prealloc.Release()
+                       output.Release()
                        return
                }
 
-               return s.emitResult(prealloc, data)
+               if output.Offset != 0 {
+                       output.SetSlice(0, s.iterLen)
+               }
+
+               return s.emitResult(output, data)
        }
 
        // fully preallocating, but not contiguously

Reply via email to