Skip to content

Commit

Permalink
apacheGH-43956: [Go][Format] Add initial Decimal32/Decimal64 implemen…
Browse files Browse the repository at this point in the history
…tation
  • Loading branch information
zeroshade committed Sep 5, 2024
1 parent e61c105 commit 8e10471
Show file tree
Hide file tree
Showing 23 changed files with 1,832 additions and 780 deletions.
2 changes: 2 additions & 0 deletions go/arrow/array/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ func init() {
arrow.TIME64: func(data arrow.ArrayData) arrow.Array { return NewTime64Data(data) },
arrow.INTERVAL_MONTHS: func(data arrow.ArrayData) arrow.Array { return NewMonthIntervalData(data) },
arrow.INTERVAL_DAY_TIME: func(data arrow.ArrayData) arrow.Array { return NewDayTimeIntervalData(data) },
arrow.DECIMAL32: func(data arrow.ArrayData) arrow.Array { return NewDecimal32Data(data) },
arrow.DECIMAL64: func(data arrow.ArrayData) arrow.Array { return NewDecimal64Data(data) },
arrow.DECIMAL128: func(data arrow.ArrayData) arrow.Array { return NewDecimal128Data(data) },
arrow.DECIMAL256: func(data arrow.ArrayData) arrow.Array { return NewDecimal256Data(data) },
arrow.LIST: func(data arrow.ArrayData) arrow.Array { return NewListData(data) },
Expand Down
2 changes: 2 additions & 0 deletions go/arrow/array/array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ func TestMakeFromData(t *testing.T) {
{name: "time64", d: &testDataType{arrow.TIME64}},
{name: "month_interval", d: arrow.FixedWidthTypes.MonthInterval},
{name: "day_time_interval", d: arrow.FixedWidthTypes.DayTimeInterval},
{name: "decimal32", d: &testDataType{arrow.DECIMAL32}},
{name: "decimal64", d: &testDataType{arrow.DECIMAL64}},
{name: "decimal128", d: &testDataType{arrow.DECIMAL128}},
{name: "decimal256", d: &testDataType{arrow.DECIMAL256}},
{name: "month_day_nano_interval", d: arrow.FixedWidthTypes.MonthDayNanoInterval},
Expand Down
8 changes: 8 additions & 0 deletions go/arrow/array/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,14 @@ func NewBuilder(mem memory.Allocator, dtype arrow.DataType) Builder {
return NewDayTimeIntervalBuilder(mem)
case arrow.INTERVAL_MONTH_DAY_NANO:
return NewMonthDayNanoIntervalBuilder(mem)
case arrow.DECIMAL32:
if typ, ok := dtype.(*arrow.Decimal32Type); ok {
return NewDecimal32Builder(mem, typ)
}
case arrow.DECIMAL64:
if typ, ok := dtype.(*arrow.Decimal64Type); ok {
return NewDecimal64Builder(mem, typ)
}
case arrow.DECIMAL128:
if typ, ok := dtype.(*arrow.Decimal128Type); ok {
return NewDecimal128Builder(mem, typ)
Expand Down
20 changes: 16 additions & 4 deletions go/arrow/array/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,18 @@ func Equal(left, right arrow.Array) bool {
case *Float64:
r := right.(*Float64)
return arrayEqualFloat64(l, r)
case *Decimal32:
r := right.(*Decimal32)
return arrayEqualDecimal(l, r)
case *Decimal64:
r := right.(*Decimal64)
return arrayEqualDecimal(l, r)
case *Decimal128:
r := right.(*Decimal128)
return arrayEqualDecimal128(l, r)
return arrayEqualDecimal(l, r)
case *Decimal256:
r := right.(*Decimal256)
return arrayEqualDecimal256(l, r)
return arrayEqualDecimal(l, r)
case *Date32:
r := right.(*Date32)
return arrayEqualDate32(l, r)
Expand Down Expand Up @@ -527,12 +533,18 @@ func arrayApproxEqual(left, right arrow.Array, opt equalOption) bool {
case *Float64:
r := right.(*Float64)
return arrayApproxEqualFloat64(l, r, opt)
case *Decimal32:
r := right.(*Decimal32)
return arrayEqualDecimal(l, r)
case *Decimal64:
r := right.(*Decimal64)
return arrayEqualDecimal(l, r)
case *Decimal128:
r := right.(*Decimal128)
return arrayEqualDecimal128(l, r)
return arrayEqualDecimal(l, r)
case *Decimal256:
r := right.(*Decimal256)
return arrayEqualDecimal256(l, r)
return arrayEqualDecimal(l, r)
case *Date32:
r := right.(*Date32)
return arrayEqualDate32(l, r)
Expand Down
Loading

0 comments on commit 8e10471

Please sign in to comment.