Skip to content

DateTrunc miss some Signature #6623

Closed

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

Activity

  1. alamb commented on Jun 11, 2023

    @alamb
    Contributor

    I will take a shot at working on this

  2. self-assigned this
    on Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions