Skip to content

Commit a7d7773

Browse files
committed
test(arreflect): add WithTemporal non-time type test, note timestamp exclusion
- Add test: FromSlice([]string{}, WithTemporal(date32)) returns ErrUnsupportedType, covering the element-type validation guard - Add inline comment explaining why timestamp is excluded from the non-time.Time check (it is already a no-op via applyTemporalOpts)
1 parent 034a9dd commit a7d7773

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

arrow/array/arreflect/reflect.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ func FromSlice[T any](vals []T, mem memory.Allocator, opts ...Option) (arrow.Arr
401401
if err := validateTemporalOpt(tOpts.Temporal); err != nil {
402402
return nil, err
403403
}
404+
// "timestamp" is excluded: it is a no-op for non-time.Time types via applyTemporalOpts.
404405
if tOpts.Temporal != "" && tOpts.Temporal != "timestamp" {
405406
goType := reflect.TypeFor[T]()
406407
deref := goType

arrow/array/arreflect/reflect_public_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ func TestFromGoSlice(t *testing.T) {
249249
_, err := FromSlice([]time.Time{}, mem, WithTemporal("invalid"))
250250
assert.ErrorIs(t, err, ErrUnsupportedType)
251251
})
252+
253+
t.Run("WithTemporal on non-time type returns error", func(t *testing.T) {
254+
_, err := FromSlice([]string{}, mem, WithTemporal("date32"))
255+
assert.ErrorIs(t, err, ErrUnsupportedType)
256+
})
252257
}
253258

254259
func TestRecordToSlice(t *testing.T) {

0 commit comments

Comments
 (0)