Ensure `to_timestamp` behaves consistently with PostgreSQL
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Is your feature request related to a problem or challenge?
In postgres, `to_timestamp` has signature `to_timestamp ( text, text ) → timestamp with time zone` and `to_timestamp ( double precision ) → timestamp with time zone`.
But we have query that has more than 2 arguments
https://github.com/apache/datafusion/blob/7ebd993fe47e78006bad33256160716f73b13cef/datafusion/sqllogictest/test_files/timestamps.slt#L362-L366
Other than that the result seems different too.
Postgres
```
postgres=# select to_timestamp(1);
to_timestamp
---------------------------
1970-01-01 07:30:01+07:30
```
Duckdb
```
D select to_timestamp(1);
┌───────────────────────────┐
│ to_timestamp(1) │
│ timestamp with time zone │
├───────────────────────────┤
│ 1970-01-01 07:30:01+07:30 │
└───────────────────────────┘
```
Datafusion
```
query P
select to_timestamp(1);
----
1970-01-01T00:00:01
```
### 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
```
D select to_timestamp('05 Dec 2000', 'DD Mon YYYY');
Binder Error: No function matches the given name and argument types 'to_timestamp(STRING_LITERAL, STRING_LITERAL)'. You might need to add explicit type casts.
Candidate functions:
to_timestamp(DOUBLE) -> TIMESTAMP WITH TIME ZONE
LINE 1: select to_timestamp('05 Dec 2000', 'DD Mon YYY...
```
https://www.postgresql.org/docs/current/functions-formatting.html
Contributor guide
Research direction
Start with the timestamps.slt case linked at lines 362-366 and compare its current behavior with PostgreSQL's documented to_timestamp signatures and results. Trace the DataFusion implementation and update the overload behavior and timestamp result, then extend or adjust the timestamp SQL logic tests to verify both forms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, rust
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100