lidavidm opened a new issue, #804:
URL: https://github.com/apache/arrow-go/issues/804

   ### 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:
   
   ```go
   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:
   
   ```go
   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


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to