Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: support cast date to timestamp with tz #14638

Open
Tracked by #14661
xudong963 opened this issue Feb 13, 2025 · 4 comments
Open
Tracked by #14661

Feature: support cast date to timestamp with tz #14638

xudong963 opened this issue Feb 13, 2025 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@xudong963
Copy link
Member

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

@xudong963 xudong963 added the enhancement New feature or request label Feb 13, 2025
@xudong963
Copy link
Member Author

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?

@friendlymatthew
Copy link
Contributor

take

@friendlymatthew
Copy link
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.

@friendlymatthew
Copy link
Contributor

friendlymatthew commented Feb 16, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants