Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-43956: [Go][Format] Add initial Decimal32/Decimal64 implementation #43958

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
env:
TINYGO_VERSION: 0.27.0
TINYGO_VERSION: 0.33.0
timeout-minutes: 60
steps:
- name: Checkout Arrow
Expand Down
38 changes: 38 additions & 0 deletions dev/archery/archery/integration/datagen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,28 @@ def generate_null_trivial_case(batch_sizes):
return _generate_file('null_trivial', fields, batch_sizes)


def generate_decimal32_case():
fields = [
DecimalField(name='f{}'.format(i), precision=precision, scale=2,
bit_width=32)
for i, precision in enumerate(range(3, 10))
]

batch_sizes = [7, 10]
return _generate_file('decimal32', fields, batch_sizes)


def generate_decimal64_case():
fields = [
DecimalField(name='f{}'.format(i), precision=precision, scale=2,
bit_width=64)
for i, precision in enumerate(range(3, 19))
]

batch_sizes = [7, 10]
return _generate_file('decimal64', fields, batch_sizes)


def generate_decimal128_case():
fields = [
DecimalField(name='f{}'.format(i), precision=precision, scale=2,
Expand Down Expand Up @@ -1883,6 +1905,22 @@ def _temp_path():
generate_decimal256_case()
.skip_tester('JS'),

generate_decimal32_case()
.skip_tester('C#')
.skip_tester('Java')
.skip_tester('JS')
.skip_tester('nanoarrow')
.skip_tester('Rust')
.skip_tester('C++'),

generate_decimal64_case()
.skip_tester('C#')
.skip_tester('Java')
.skip_tester('JS')
.skip_tester('nanoarrow')
.skip_tester('Rust')
.skip_tester('C++'),

generate_datetime_case(),

generate_duration_case(),
Expand Down
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
Loading