Skip to content

DateTrunc miss some Signature #6623

@jackwener

Description

@jackwener

Describe the bug

Current DateTrunc Signature is

     BuiltinScalarFunction::DateTrunc => Signature::exact(
            vec![
                DataType::Utf8,
                DataType::Timestamp(TimeUnit::Nanosecond, None),
            ],
            fun. Volatility(),
        ),

TimeUnit should also can be Second | millsecond ...

Because return type is determined by Signature, so it will cause wrong expect type.

explain verbose select arrow_typeof(date_trunc('minute', to_timestamp_seconds(61)));
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
| plan_type                                                  | plan                                                                                                                           |
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
| initial_logical_plan                                       | Projection: arrow_typeof(date_trunc(Utf8("minute"), to_timestamp_seconds(Int64(61))))                                          |
|                                                            |   EmptyRelation                                                                                                                |
| logical_plan after inline_table_scan                       | SAME TEXT AS ABOVE                                                                                                             |
| logical_plan after type_coercion                           | Projection: arrow_typeof(date_trunc(Utf8("minute"), CAST(to_timestamp_seconds(Int64(61)) AS Timestamp(Nanosecond, None))))     |
|                                                            |   EmptyRelation                                                                                                                |

To Reproduce

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

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