-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Ensure to_timestamp
behaves consistently with PostgreSQL
#13351
Comments
The difference in As for why the DF version has multiple arguments - it's because it's better. None of those other systems were designed with handling human entered data in mind. Dates and times especially are consistently different, especially if you go outside a particular locality (US - mm/dd/yyyy, most everywhere else dd/mm/yyyy as a very simple example). If you ever have to clean 100's of billions of records and try to get consist dates and timestamps out of them having a function that accepts many possible formats to try is very refreshing. The alternative of when/when/when/when/when/............./otherwise statements is substantially poorer ux. For a single field I have up to 10 different formats I must try - and this is just for US specific data! |
Great, but what each argument represented for is unclear to me. I can only find this query in test. |
I'll point you to the documentation :) The first arg is the string to parse, the remaining are chrono formats to test. More examples in ... the examples |
In the documentation the signature seems there can only be one expression?
The query has 2 expressions and 3 follow on chrono format |
Ah, I see the confusion. So that query was a test of to_timestamp with multiple chrono formats, one of which is malformed. So what you are actually seeing is 1 expression and 4 formats of which only the last 3 are valid chrono formats. I should likely have used a different string for the first chrono format ('this is an invalid chrono format' maybe). |
Should we return error if we have invalid chrono format? |
That is a very good question. There must have been I reason I didn't do that when I coded this up but right now I can't recall why it would have been. Let me think about that for a day and see if I can recall a good reason. |
Is your feature request related to a problem or challenge?
In postgres,
to_timestamp
has signatureto_timestamp ( text, text ) → timestamp with time zone
andto_timestamp ( double precision ) → timestamp with time zone
.But we have query that has more than 2 arguments
datafusion/datafusion/sqllogictest/test_files/timestamps.slt
Lines 362 to 366 in 7ebd993
Other than that the result seems different too.
Postgres
Duckdb
Datafusion
Describe the solution you'd like
Change the function signature to be consistent with Postgres.
Change the result to be consistent with Postgres.
Describe alternatives you've considered
No response
Additional context
Duckdb doesn't support (text, text) signature
https://www.postgresql.org/docs/current/functions-formatting.html
The text was updated successfully, but these errors were encountered: