-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Question: to_char(date, timstamp format)
#14536
Comments
FYI, Postgres supports this, so I think it's a feature. Schema (PostgreSQL v17)
|
If you cast the date to a timestamp that would work, but the syntax you provided would not match a date and thus it'll throw the format error. Any of the following would work: select to_char('2023-09-04'::date, '%Y-%m-%d');
select to_char('2023-09-04 00:00:00'::timestamp, '%Y-%m-%dT%H:%M:%S%.3f');
select to_char(arrow_cast('2023-09-04'::date, 'Timestamp(Second, None)'), '%Y-%m-%dT%H:%M:%S%.3f'); |
@xudong963 maybe we should make the error message better? |
Yes, this is a good point (if we don't plan to support the syntax) |
I had the impression (although perhaps it is dated) that datafusion sought to be compatible with postgres to the extent reasonable. Assuming thats still the case is there a reason we wouldnt want to fix this? |
I'm sorry, I didn't mean to imply in any way that this is something that should not be looked into. I was just providing alternatives to get @xudong963 past this issue in the meantime. The solution is likely to try casting the date to a timestamp then applying the format if any of the provided formats don't succeed at first. |
I agree -- fixing this issue seems reasonable to me. Thanks @Omega359 |
@Omega359 totally understood and appreciate the alternatives :) |
It seems that we don't support
I want to ensure if this is an unsupported feature or if the SQL semantics don't support this usage.
Thanks!
The text was updated successfully, but these errors were encountered: