alamb opened a new issue, #3980:
URL: https://github.com/apache/arrow-datafusion/issues/3980
**Describe the bug**
I would like to be able to find the current date, or the current day of
week, etc
DataFusion supports `now()` and `extract (hour from <timestamp>)` syntax ✅
However, you can't use `extract` with the value of `now()` 😢
**To Reproduce**
```
❯ select extract (day from now());
Plan("Coercion from [Utf8, Timestamp(Nanosecond, Some(\"UTC\"))] to the
signature OneOf([Exact([Utf8, Date32]), Exact([Utf8, Date64]), Exact([Utf8,
Timestamp(Second, None)]), Exact([Utf8, Timestamp(Microsecond, None)]),
Exact([Utf8, Timestamp(Millisecond, None)]), Exact([Utf8, Timestamp(Nanosecond,
None)])]) failed.")
```
**Expected behavior**
I expect the day part of `now()` to be extracted as in postgres:
```sql
postgres=# select extract(day from now());
extract
---------
27
(1 row)
```
Note that the error seems to be that DataFusion can't coerce a
`Timestamp(Nanosecond, "UTC")` to `Timestamp(Nanosecond, None)` -- aka it is
related to timezones
You can work around the problem by explicitly casting the output of `now()`
to timestamp (not timestamptz):
```sql
❯ select extract (day from cast(now() as timestamp));
+-----------------------------+
| datepart(Utf8("DAY"),now()) |
+-----------------------------+
| 27 |
+-----------------------------+
```
**Additional context**
This was reported by early (internal) users of IOx
--
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]