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 378b9233 fix(arrow/compute): fix scalar comparison panic (#518)
378b9233 is described below

commit 378b92334ee2d2e5e847d20eba846b70714db1e3
Author: Matt Topol <[email protected]>
AuthorDate: Wed Sep 24 10:49:07 2025 -0400

    fix(arrow/compute): fix scalar comparison panic (#518)
    
    ### Rationale for this change
    fixes #503
    
    ### What changes are included in this PR?
    Properly limit the slice when calling `op` in
    `comparePrimitiveArrayScalar` like we do for
    `comparePrimitiveScalarArray` as per #464
    
    ### Are these changes tested?
    Yes, the unit test is updated to account for this situation
    
    ### Are there any user-facing changes?
    scenario will no longer panic
---
 arrow/compute/exprs/exec_test.go                   | 48 ++++++++++++++++------
 .../compute/internal/kernels/scalar_comparisons.go |  2 +-
 2 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/arrow/compute/exprs/exec_test.go b/arrow/compute/exprs/exec_test.go
index f56b9f77..ea672d03 100644
--- a/arrow/compute/exprs/exec_test.go
+++ b/arrow/compute/exprs/exec_test.go
@@ -743,7 +743,7 @@ func TestDecimalFilterLarge(t *testing.T) {
                                db.Append(d)
                        }
 
-                       rec := array.NewRecord(schema, 
[]arrow.Array{db.NewArray()}, int64(tc.n))
+                       rec := array.NewRecordBatch(schema, 
[]arrow.Array{db.NewArray()}, int64(tc.n))
 
                        extSet := exprs.GetExtensionIDSet(ctx)
                        builder := exprs.NewExprBuilder(extSet)
@@ -761,23 +761,45 @@ func TestDecimalFilterLarge(t *testing.T) {
                        }, true)
                        rq.NoError(err, "Failed to create Decimal128 literal")
 
-                       b, err := builder.CallScalar("less", nil,
-                               builder.FieldRef("col"),
-                               builder.Literal(lit),
-                       )
+                       t.Run("array_scalar", func(t *testing.T) {
+                               b, err := builder.CallScalar("less", nil,
+                                       builder.FieldRef("col"),
+                                       builder.Literal(lit),
+                               )
 
-                       rq.NoError(err, "Failed to call scalar")
+                               rq.NoError(err, "Failed to call scalar")
 
-                       e, err := b.BuildExpr()
-                       rq.NoError(err, "Failed to build expression")
+                               e, err := b.BuildExpr()
+                               rq.NoError(err, "Failed to build expression")
 
-                       ctx = exprs.WithExtensionIDSet(ctx, extSet)
+                               ctx = exprs.WithExtensionIDSet(ctx, extSet)
 
-                       dr := compute.NewDatum(rec)
-                       defer dr.Release()
+                               dr := compute.NewDatum(rec)
+                               defer dr.Release()
 
-                       _, err = exprs.ExecuteScalarExpression(ctx, schema, e, 
dr)
-                       rq.NoError(err, "Failed to execute scalar expression")
+                               _, err = exprs.ExecuteScalarExpression(ctx, 
schema, e, dr)
+                               rq.NoError(err, "Failed to execute scalar 
expression")
+                       })
+
+                       t.Run("scalar_array", func(t *testing.T) {
+                               b, err := builder.CallScalar("less", nil,
+                                       builder.Literal(lit),
+                                       builder.FieldRef("col"),
+                               )
+
+                               rq.NoError(err, "Failed to call scalar")
+
+                               e, err := b.BuildExpr()
+                               rq.NoError(err, "Failed to build expression")
+
+                               ctx = exprs.WithExtensionIDSet(ctx, extSet)
+
+                               dr := compute.NewDatum(rec)
+                               defer dr.Release()
+
+                               _, err = exprs.ExecuteScalarExpression(ctx, 
schema, e, dr)
+                               rq.NoError(err, "Failed to execute scalar 
expression")
+                       })
                })
        }
 }
diff --git a/arrow/compute/internal/kernels/scalar_comparisons.go 
b/arrow/compute/internal/kernels/scalar_comparisons.go
index 6d7611f7..aed44da6 100644
--- a/arrow/compute/internal/kernels/scalar_comparisons.go
+++ b/arrow/compute/internal/kernels/scalar_comparisons.go
@@ -110,7 +110,7 @@ func comparePrimitiveArrayScalar[T arrow.FixedWidthType](op 
cmpScalarRight[T, T]
                }
 
                for j := 0; j < nbatches; j++ {
-                       op(left, rightVal, tmpOutSlice)
+                       op(left[:batchSize], rightVal, tmpOutSlice)
                        left = left[batchSize:]
                        packBits(tmpOutput, out)
                        out = out[batchSize/8:]

Reply via email to