liukun4515 opened a new issue, #6951:
URL: https://github.com/apache/arrow-datafusion/issues/6951
Do we have any method to convert or cast the integer
type/integer expr with the timeunit to the interval?
@waitingkuo @alamb
I want to implement a app or function like this `datetime + integer with
timeunit`, and the timeunit may be `year`,`month`,`day`.
I can't find the any method to convert the `integer with timeunit` to the
interval, but in the PG which has a function `make_interval()`
https://www.postgresql.org/docs/current/functions-datetime.html can do this.
I just can find a way to resolve the issue by using the `concat` method.
For example: I have a table like below, and want to convert the `b` with
`day`unit to interval
```
❯ \d test
+---------------+--------------+------------+-------------+-----------+-------------+
| table_catalog | table_schema | table_name | column_name | data_type |
is_nullable |
+---------------+--------------+------------+-------------+-----------+-------------+
| datafusion | public | test | a | Date32 | NO
|
| datafusion | public | test | b | Int64 | NO
|
+---------------+--------------+------------+-------------+-----------+-------------+
2 rows in set. Query took 0.013 seconds.
```
Using the concat to get the `utf8` expr which can be casted to interval.
```
❯ select cast(concat(b,' day') as interval), b from test;
+-------------------------------------------------------+---+
| concat(test.b,Utf8(" day")) | b |
+-------------------------------------------------------+---+
| 0 years 0 mons 2 days 0 hours 0 mins 0.000000000 secs | 2 |
+-------------------------------------------------------+---+
```
_Originally posted by @liukun4515 in
https://github.com/apache/arrow-datafusion/issues/3148#issuecomment-1631812195_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]