Skip to content

date_trunc always returns Timestamp(Nanosecond, None) #5750

Description

@waitingkuo

Describe the bug

while i try to use date_trunc to Timestamp(Second, None), it returns Timestamp(Nanosecond, None)

select date_trunc('minute', to_timestamp_seconds(61));
+---------------------------------------------------------+
| datetrunc(Utf8("minute"),totimestampseconds(Int64(61))) |
+---------------------------------------------------------+
| 1970-01-01T00:01:00                                     |
+---------------------------------------------------------+
1 row in set. Query took 0.003 seconds.

❯ select arrow_typeof(date_trunc('minute', to_timestamp_seconds(61)));
+----------------------------------------------------------------------+
| arrowtypeof(datetrunc(Utf8("minute"),totimestampseconds(Int64(61)))) |
+----------------------------------------------------------------------+
| Timestamp(Nanosecond, None)                                          |
+----------------------------------------------------------------------+
1 row in set. Query took 0.003 seconds.

The behavior is similar while I apply date_trunc to Timestamp with Millis and Micros.

To Reproduce

select arrow_typeof(date_trunc('minute', to_timestamp_seconds(61)));
+----------------------------------------------------------------------+
| arrowtypeof(datetrunc(Utf8("minute"),totimestampseconds(Int64(61)))) |
+----------------------------------------------------------------------+
| Timestamp(Nanosecond, None)                                          |
+----------------------------------------------------------------------+
1 row in set. Query took 0.003 seconds.

Expected behavior

select arrow_typeof(date_trunc('minute', to_timestamp_seconds(61)));
+----------------------------------------------------------------------+
| arrowtypeof(datetrunc(Utf8("minute"),totimestampseconds(Int64(61)))) |
+----------------------------------------------------------------------+
| Timestamp(Second, None)                                          |
+----------------------------------------------------------------------+
1 row in set. Query took 0.003 seconds.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions