Skip to content

Conversation

@maxburke
Copy link
Contributor

Closes #11039

@github-actions github-actions bot added the logical-expr Logical plan and expressions label Jun 20, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @maxburke -- I think this PR needs some tests to show the behavior

Perhaps you could add a .slt test

I also wonder if it would be confusing for people to have coercion done automatically

It is also possible to make a int into a timestamp explicitly using one of the to_timestamp functions:

https://datafusion.apache.org/user-guide/sql/scalar_functions.html#to-timestamp

> select arrow_typeof(to_timestamp(12345)), to_timestamp(123456789);
+------------------------------------------+--------------------------------+
| arrow_typeof(to_timestamp(Int64(12345))) | to_timestamp(Int64(123456789)) |
+------------------------------------------+--------------------------------+
| Timestamp(Nanosecond, None)              | 1973-11-29T21:33:09            |
+------------------------------------------+--------------------------------+
1 row(s) fetched.
Elapsed 0.001 seconds.

> select arrow_typeof(to_timestamp(123456789)), to_timestamp(123456789);
+----------------------------------------------+--------------------------------+
| arrow_typeof(to_timestamp(Int64(123456789))) | to_timestamp(Int64(123456789)) |
+----------------------------------------------+--------------------------------+
| Timestamp(Nanosecond, None)                  | 1973-11-29T21:33:09            |
+----------------------------------------------+--------------------------------+
1 row(s) fetched.
Elapsed 0.001 seconds.

> select arrow_typeof(to_timestamp_millis(123456789)), to_timestamp_millis(123456789);
+-----------------------------------------------------+---------------------------------------+
| arrow_typeof(to_timestamp_millis(Int64(123456789))) | to_timestamp_millis(Int64(123456789)) |
+-----------------------------------------------------+---------------------------------------+
| Timestamp(Millisecond, None)                        | 1970-01-02T10:17:36.789               |
+-----------------------------------------------------+---------------------------------------+
1 row(s) fetched.
Elapsed 0.001 seconds.

@alamb
Copy link
Contributor

alamb commented Jun 22, 2024

Marking as draft so it doesn't appear on the "needs review" list while feedback is addressed

@alamb alamb marked this pull request as draft June 22, 2024 11:37
@github-actions
Copy link

Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale PR has not had any activity for some time label Aug 22, 2024
@github-actions github-actions bot closed this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions Stale PR has not had any activity for some time

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Int64 should be coercible to timestamp types

2 participants