Sunyue commented on issue #404:
URL: https://github.com/apache/arrow-go/issues/404#issuecomment-3072081087

   Please find my test case below:
   ```go
   import (
        "testing"
   
        "github.com/apache/arrow-go/v18/arrow"
        "github.com/apache/arrow-go/v18/arrow/array"
        "github.com/apache/arrow-go/v18/arrow/compute"
        "github.com/apache/arrow-go/v18/arrow/compute/exprs"
        "github.com/apache/arrow-go/v18/arrow/memory"
        "github.com/stretchr/testify/require"
        "github.com/substrait-io/substrait-go/v4/expr"
        "github.com/substrait-io/substrait-go/v4/types"
   )
   
   func Test_Types(t *testing.T) {
        t.Parallel()
   
        tt := []struct {
                name   string
                schema func() *arrow.Schema
                record func(rq *require.Assertions, schema *arrow.Schema) 
arrow.Record
                val    func(rq *require.Assertions) expr.Literal
        }{
                {
                        name: "expect arrow.TIME64 (ns) ok",
                        schema: func() *arrow.Schema {
                                field := arrow.Field{
                                        Name:     "col",
                                        Type:     &arrow.Time64Type{Unit: 
arrow.Nanosecond},
                                        Nullable: true,
                                }
   
                                return arrow.NewSchema([]arrow.Field{field}, 
nil)
                        },
                        record: func(rq *require.Assertions, schema 
*arrow.Schema) arrow.Record {
                                b := 
array.NewTime64Builder(memory.DefaultAllocator, &arrow.Time64Type{Unit: 
arrow.Nanosecond})
                                defer b.Release()
   
                                t1, err := 
arrow.Time64FromString("10:00:00.000000", arrow.Nanosecond)
                                rq.NoError(err, "Failed to create Time64 value")
   
                                b.AppendValues([]arrow.Time64{t1}, []bool{true})
   
                                return array.NewRecord(schema, 
[]arrow.Array{b.NewArray()}, 1)
                        },
                        val: func(rq *require.Assertions) expr.Literal {
                                v, err := 
arrow.Time64FromString("11:00:00.000000", arrow.Nanosecond)
                                rq.NoError(err, "Failed to create Time64 value")
   
                                pt := &types.PrecisionTime{
                                        Precision: int32(arrow.Nanosecond) * 3,
                                        Value:     int64(v),
                                }
   
                                lit, err := expr.NewLiteral(pt, true)
                                rq.NoError(err, "Failed to create literal")
   
                                return lit
                        },
                },
        }
   
        for _, tc := range tt {
                t.Run(tc.name, func(t *testing.T) {
                        t.Parallel()
   
                        ctx := t.Context()
                        rq := require.New(t)
                        schema := tc.schema()
                        record := tc.record(rq, schema)
   
                        extSet := exprs.GetExtensionIDSet(ctx)
                        builder := exprs.NewExprBuilder(extSet)
   
                        err := builder.SetInputSchema(schema)
                        rq.NoError(err, "Failed to set input schema")
   
                        b, err := builder.CallScalar("less", nil,
                                builder.FieldRef("col"),
                                builder.Literal(tc.val(rq)),
                        )
   
                        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(record)
                        defer dr.Release()
   
                        _, err = exprs.ExecuteScalarExpression(ctx, schema, e, 
dr)
                        rq.NoError(err, "Failed to execute scalar expression")
                })
        }
   }
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to