Skip to content

Feature: support cast date to timestamp with tz #14638

Closed

Description

@xudong963

Is your feature request related to a problem or challenge?

> select to_char(arrow_cast('2023-09-04'::date, 'Timestamp(Second, Some("UTC"))'), '%Y-%m-%dT%H:%M:%S%.3f');
This feature is not implemented: Unsupported CAST from Date32 to Timestamp(Second, Some("UTC"))

Describe the solution you'd like

No response

Describe alternatives you've considered

Maybe it should be implemented in arrow-rs?

Additional context

No response

Activity

  1. xudong963 commented on Feb 14, 2025

    @xudong963
    MemberAuthor

    It seems that Date32/Date64 doesn't support TZ, so if we want to support the cast, we should add TZ to Date32/Date64 firstly?

  2. friendlymatthew commented on Feb 15, 2025

    @friendlymatthew
    Contributor

    take

  3. friendlymatthew commented on Feb 16, 2025

    @friendlymatthew
    Contributor

    It seems that Date32/Date64 doesn't support TZ, so if we want to support the cast, we should add TZ to Date32/Date64 firstly?

    I'm not sure if Date types should be time-zone aware. Postgres has a similar Date time and does not allow dates with associated time zones.

    However when casting a Date into a Timestamp, we should definitely support various time zones! I've posted a PR for that.

  4. friendlymatthew commented on Feb 16, 2025

    @friendlymatthew
    Contributor

    Datafusion-wise, I tested this feature in this branch and it works as expected:

    > select to_char(arrow_cast('2023-09-04'::date, 'Timestamp(Second, Some("UTC"))'), '%Y-%m-%dT%H:%M:%S%.3f');
    +--------------------------------------------------------------------------------------------------------------+
    | to_char(arrow_cast(Utf8("2023-09-04"),Utf8("Timestamp(Second, Some("UTC"))")),Utf8("%Y-%m-%dT%H:%M:%S%.3f")) |
    +--------------------------------------------------------------------------------------------------------------+
    | 2023-09-04T00:00:00.000                                                                                      |
    +--------------------------------------------------------------------------------------------------------------+
    1 row(s) fetched.
    Elapsed 0.027 seconds.

    Once apache/arrow-rs#7141 lands, I'll follow up with some test cases in cast.slt.

  5. friendlymatthew commented on Feb 25, 2025

    @friendlymatthew
    Contributor

    The next release of arrow should support this mini feature! @Omega359, is there a timeline for upgrading the arrow dependency in datafusion?

  6. Omega359 commented on Feb 25, 2025

    @Omega359
    Contributor

    arrow-rs releases are not in sync with df releases so it will likely be df 47 or 48

  7. Omega359 commented on Mar 26, 2025

    @Omega359
    Contributor

    I believe the arrow update is in the arrow 54.3.0 release so once DF is upgraded to that release we can verify it in DF.

  8. friendlymatthew commented on Mar 27, 2025

    @friendlymatthew
    Contributor

    I believe the arrow update is in the arrow 54.3.0 release so once DF is upgraded to that release we can verify it in DF.

    Thank you @Omega359. I'll make sure to follow up with some SLT test cases.

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

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions