-
Notifications
You must be signed in to change notification settings - Fork 79
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
Handle Date Underflow #612
base: main
Are you sure you want to change the base?
Conversation
I'm a bit confused. How is this supposed to work? These functions are not being called afaict. |
I should've asked in the original issue, but I did a quick look and didn't see any files that looked like they control date formatting and verification, could you point me to the file(s) that handle that feature? Would it be the original file referenced in #595 or src/pgduckdb_types by any chance? |
I updated the original issue to include this query that triggers these underflowing dates: SELECT * FROM duckdb.query($$
select
'5877642-06-25 (BC)'::date as date,
'290309-12-22 (BC) 00:00:00'::timestamp as timestamp,
'290309-12-22 (BC) 00:00:00'::timestamp_s as timestamp_s,
'290309-12-22 (BC) 00:00:00'::timestamp_ms as timestamp_ms,
'290309-12-22 (BC) 00:17:30+00:17'::timestamptz as timestamptz,
$$);
date │ timestamp │ timestamp_s │ timestamp_ms │ timestamptz
───────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼─────────────────────────────────
5881580-07-14 │ 294247-01-10 08:01:49.551616 │ 294247-01-10 08:01:49.551616 │ 294247-01-10 08:01:49.551616 │ 294247-01-10 09:02:19.551616+01
(1 row) And yes this conversion between PG and DuckDB date format is being done in the |
The conversion is done in these functions to be specific: pg_duckdb/src/pgduckdb_types.cpp Lines 215 to 255 in 82d3a0f
|
Attempting to resolve #595
Takes in a date (MM-DD-YYYY) and formats it to ISO 8601 (YYYY-MM-DD), then compares if it is below the lowest PostgreSQL date (4713 BC or -4712-01-01 in ISO 8601). Truncates the entered date to the lowest Postgres if it is further in the past than Postgres allows. Similar logic is applied if the date is further in the future than Postgres allows. Returns the user-entered date in ISO 8601 format if it is a valid date