senekis opened a new issue, #36935:
URL: https://github.com/apache/arrow/issues/36935

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   The MarshalJSON for Timestamp array is always converting it to nanoseconds 
and to then build the Time formatted
   ```go
   func (t Timestamp) ToTime(unit TimeUnit) time.Time {
        if unit == Second {
                return time.Unix(int64(t), 0).UTC()
        }
        return time.Unix(0, int64(t)*int64(unit.Multiplier())).UTC()
   }
   ```
   
   but if the milliseconds number is already big, doing the nanoseconds 
conversion will cause the result number to don't fit in `int64` returning a 
wrong date.
   
   For example the milliseconds `11865225600000` in nanoseconds is 
`1.18652256e+19` too big for an int64.
   
   ## How to reproduce the issue
   
   ```go
   package main
   
   import (
        "fmt"
        "log"
   
        "github.com/apache/arrow/go/v12/arrow"
        "github.com/apache/arrow/go/v12/arrow/array"
        "github.com/apache/arrow/go/v12/arrow/memory"
   )
   
   func main() {
        mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
   
        dt := &arrow.TimestampType{Unit: arrow.Millisecond, TimeZone: "UTC"}
        b := array.NewTimestampBuilder(mem, dt)
   
        b.AppendNull()
        b.Append(11865225600000)
   
        arr := b.NewArray().(*array.Timestamp)
        defer arr.Release()
   
        arrBytes, err := arr.MarshalJSON()
        if err != nil {
                log.Fatal(err)
        }
   
        // It prints [null,"1761-06-10 00:25:26.290448384"] but should print 
[null,"2345-12-30 00:00:00"]
        fmt.Println(string(arrBytes))
   }
   ```
   
   ### Component(s)
   
   Go


-- 
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