Skip to content

Non-constant DATE_TRUNC expression regression for values before epoch #18334

Description

@sadboy

Describe the bug

On DF 50, DATE_TRUNC function sometimes returns off-by-1 result.

To Reproduce

DataFusion CLI v50.3.0
> select d as datetime,
DATE_TRUNC('hour', d) as hour_from_column,
DATE_TRUNC('hour', (timestamp '1900-06-15 07:09:00')) as hour_from_const
from (values (timestamp '1900-06-15 07:09:00')) as T(d);
+---------------------+---------------------+---------------------+
| datetime            | hour_from_column    | hour_from_const     |
+---------------------+---------------------+---------------------+
| 1900-06-15T07:09:00 | 1900-06-15T08:00:00 | 1900-06-15T07:00:00 |
+---------------------+---------------------+---------------------+
1 row(s) fetched. 
Elapsed 0.006 seconds.

Expected behavior

hour_from_column should have the same value as hour_from_const

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingregressionSomething that used to work no longer does

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions