Skip to content

[Go] RecordFromJSON does not handle integer values not representable by double #804

@lidavidm

Description

@lidavidm

Describe the bug, including details regarding any error messages, version, and platform.

This limits the usefulness of RecordFromJSON for testing, and implies we may have been writing incorrect tests.

You silently get wrong data:

package main

import (
	"bytes"
	"fmt"
	"log"

	"github.com/apache/arrow-go/v18/arrow"
	"github.com/apache/arrow-go/v18/arrow/array"
	"github.com/apache/arrow-go/v18/arrow/memory"
)

func main() {
	mem := memory.DefaultAllocator
	dt := arrow.FixedWidthTypes.Duration_s
	record, _, err := array.FromJSON(mem, dt, bytes.NewReader([]byte("[9223372036854775807]")))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(record)
}

Result:

[-9223372036854775808]

Commonly, large integers are represented as strings in JSON to get around this. That doesn't work:

package main

import (
	"bytes"
	"fmt"
	"log"

	"github.com/apache/arrow-go/v18/arrow"
	"github.com/apache/arrow-go/v18/arrow/array"
	"github.com/apache/arrow-go/v18/arrow/memory"
)

func main() {
	mem := memory.DefaultAllocator
	dt := arrow.FixedWidthTypes.Duration_s
	record, _, err := array.FromJSON(mem, dt, bytes.NewReader([]byte(`["9223372036854775807"]`)))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(record)
}

Result:

2026/05/07 15:36:14 json: cannot unmarshal 9223372036854775807 into Go value of type arrow.Duration
exit status 1

Component(s)

Other

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions