[C++][Python] Incorrect result for `floor_temporal` with 3 and 'year'
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the bug, including details regarding any error messages, version, and platform.
```python
import pyarrow as pa
import pyarrow.compute as pc
import duckdb
print(duckdb.sql(
"""
from values (timestamp '1970-01-01') df(a)
select time_bucket('3 years', "a", timestamp '1970-01-01')
"""
))
print(pc.floor_temporal(pa.array([datetime(1970, 1, 1)]), 3, 'year'))
```
Outputs:
```
┌────────────────────────────────────────────────────────────┐
│ time_bucket('3 years', a, CAST('1970-01-01' AS TIMESTAMP)) │
│ timestamp │
├────────────────────────────────────────────────────────────┤
│ 1970-01-01 00:00:00 │
└────────────────────────────────────────────────────────────┘
[
1968-01-01 00:00:00.000000
]
```
The DuckDB output differs from the PyArrow one. Given that the pyarrow docs say
> By default, the origin is 1970-01-01T00:00:00.
I would expect it to be aligned with DuckDB when specifying `timestamp '1970-01-01'` as origin.
In fact, if I use `36, 'month'`, then PyArrow also returns `'1970-01-01'`. The fact that `3, 'year'` differs from `3*12, 'month'` suggests to me that there's a bug
```python
In [6]: pc.floor_temporal(arr, 3, 'year')
Out[6]:
[
1968-01-01 00:00:00.000000
]
In [7]: pc.floor_temporal(arr, 3*12, 'month')
Out[7]:
[
1970-01-01 00:00:00.000000
]
```
### Component(s)
Python
Contributor guide
Assessment
This issue has not been assessed yet.