-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Can not use extract <part>
on the value of now()
#3980
Comments
i guess this is similar as #3096 |
I'll plan to try and improve things here myself in the next week or two if no one else has a chance |
i'm working on this apache/arrow-rs#1380 which is probably one of the root case for in postgres btw, postgres doc recommend use
|
I am not quite sure what you are asking. Are you asking if we should follow postgres so that If so I don't have any strong opinion 🤷 |
datafusion currently returns ❯ select date_part('second', timestamp '2000-01-01T00:00:00.1');
+--------------------------------------------------------+
| datepart(Utf8("second"),Utf8("2000-01-01T00:00:00.1")) |
+--------------------------------------------------------+
| 0 |
+--------------------------------------------------------+
1 row in set. Query took 0.000 seconds. and ❯ select extract(second from timestamp '2000-01-01T00:00:00.1');
+--------------------------------------------------------+
| datepart(Utf8("SECOND"),Utf8("2000-01-01T00:00:00.1")) |
+--------------------------------------------------------+
| 0 |
+--------------------------------------------------------+
1 row in set. Query took 0.000 seconds. while postgresql has willy=# select date_part('second', timestamp '2000-01-01T00:00:00.1');
date_part
-----------
0.1
(1 row) which returns double precision and willy=# select extract(second from timestamp '2000-01-01T00:00:00.1');
extract
----------
0.100000
(1 row) which returns decimal is it recommended to follow postgresql's return type? |
That probably makes the most sense
Agreed -- can you file a ticket? (basically copy/paste #3980 (comment) 😆 ) |
Thanks @waitingkuo -- We'll get there some day! |
This should be fixed by #4548 |
I confirmed that on master the query works now:
Thank you @comphead ❤️ |
Describe the bug
I would like to be able to find the current date, or the current day of week, etc
DataFusion supports
now()
andextract (hour from <timestamp>)
syntax ✅However, you can't use
extract
with the value ofnow()
😢To Reproduce
Expected behavior
I expect the day part of
now()
to be extracted as in postgres:Note that the error seems to be that DataFusion can't coerce a
Timestamp(Nanosecond, "UTC")
toTimestamp(Nanosecond, None)
-- aka it is related to timezonesYou can work around the problem by explicitly casting the output of
now()
to timestamp (not timestamptz):Additional context
This was reported by early (internal) users of IOx
The text was updated successfully, but these errors were encountered: