Skip to content
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 dates that underflow differently #595

Open
JelteF opened this issue Feb 14, 2025 · 1 comment · May be fixed by #612
Open

Handle dates that underflow differently #595

JelteF opened this issue Feb 14, 2025 · 1 comment · May be fixed by #612
Labels
bug Something isn't working good first issue Good for newcomers incorrect result Bugs that return incorrect data types Issues related to type conversions

Comments

@JelteF
Copy link
Collaborator

JelteF commented Feb 14, 2025

Description

DuckDB dates can be further into the past than Postgres dates. We should either truncate the date to the lowest possible date that's representable in Postgres, or we should throw an error. Underflowing and returning a date in the future is the worst possible behavior.

This is a query that creates 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,
$$);
     datetimestamp           │         timestamp_s          │         timestamp_ms         │           timestamptz
───────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼─────────────────────────────────
 5881580-07-14294247-01-10 08:01:49.551616294247-01-10 08:01:49.551616294247-01-10 08:01:49.551616294247-01-10 09:02:19.551616+01
(1 row)

Example of underflowing dates are in this test:

date | 07-14-5881580
timestamp | Sun Jan 10 08:01:49.551616 294247
timestamp_s | Sun Jan 10 08:01:49.551616 294247
timestamp_ms | Sun Jan 10 08:01:49.551616 294247
timestamp_ns | Wed Sep 22 00:00:00 1677
timestamp_tz | Sun Jan 10 00:01:49.551616 294247 PST

Found by #577

@JelteF JelteF added bug Something isn't working good first issue Good for newcomers incorrect result Bugs that return incorrect data types Issues related to type conversions labels Feb 14, 2025
This was referenced Feb 17, 2025
@kamuli4
Copy link

kamuli4 commented Feb 17, 2025

Hi, I've created a pull request with my attempt to fix this issue. I closed #611 because it was accidentally opened as a draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers incorrect result Bugs that return incorrect data types Issues related to type conversions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants