vdpoora opened a new issue, #1591:
URL: https://github.com/apache/arrow-go/issues/1591
### Describe the bug, including details regarding any error messages,
version, and platform.
`CeilTemporal` with unit Year, Quarter or Month moves a value that is
already on a period boundary to the next period. This happens with the default
options (`CeilIsStrictlyGreater: false`). v18.8.0 returns the input unchanged.
Day is not affected.
Version: v18.9.0. Regressed in 6542b630f84dda25715f6238027cc1eed9d114c6
(#1127).
Repro:
```go
func TestCeilAlignedCalendar(t *testing.T) {
mem := memory.NewGoAllocator()
in, _, err := array.FromJSON(mem, &arrow.TimestampType{Unit:
arrow.Second},
strings.NewReader(`["1970-01-01T00:00:00",
"2021-01-01T00:00:00"]`))
if err != nil {
t.Fatal(err)
}
defer in.Release()
for _, unit := range
[]compute.RoundTemporalUnit{compute.RoundTemporalYear,
compute.RoundTemporalQuarter, compute.RoundTemporalMonth,
compute.RoundTemporalDay} {
res, err := compute.CeilTemporal(context.Background(),
compute.RoundTemporalOptions{Multiple: 1, Unit: unit}, compute.NewDatum(in))
if err != nil {
t.Fatal(err)
}
out := res.(*compute.ArrayDatum).MakeArray()
if !array.Equal(in, out) {
t.Errorf("unit=%d: in=%v out=%v", unit, in, out)
}
out.Release()
res.Release()
}
}
```
Output on v18.9.0 (unit 0 = Year, 1 = Quarter, 2 = Month):
```
--- FAIL: TestCeilAlignedCalendar (0.00s)
unit=0: in=[0 1609459200] out=[31536000 1640995200]
unit=1: in=[0 1609459200] out=[7776000 1617235200]
unit=2: in=[0 1609459200] out=[2678400 1612137600]
```
The test passes on the parent of 6542b63 (72e9a56).
Cause: in `arrow/compute/internal/kernels/rounding.go`,
`roundTimestampCalendar`, the `RoundUp` branches for Year, Quarter and Month
always add `multiple`. Before #1127 they had the guard `if
opts.CeilIsStrictlyGreater || !t.Equal(periodStart)`. The Day branch still has
it.
### Component(s)
Go
---
_beep boop, a clanker found this and wrote it up 🤖_
--
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]