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

Fix time_bucket_ng() behavior with origin argument #3527

Merged
merged 1 commit into from Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/time_bucket.c
Expand Up @@ -457,7 +457,7 @@ ts_time_bucket_ng_date(PG_FUNCTION_ARGS)

delta = date - origin_date;
bucket_number = delta / interval->day;
date = bucket_number * interval->day;
date = origin_date + bucket_number * interval->day;
}

PG_RETURN_DATEADT(date);
Expand Down
24 changes: 12 additions & 12 deletions test/expected/timestamp.out
Expand Up @@ -1513,18 +1513,18 @@ FROM generate_series('2020-01-01' :: date, '2020-01-12', '1 day') AS ts,
unnest(array[ts :: date]) AS d;
d | d1 | d2 | d3 | w1 | w1d2
------------+------------+------------+------------+------------+------------
2020-01-01 | 2000-01-01 | 2000-01-01 | 2000-01-01 | 2000-01-01 | 2000-01-01
2020-01-02 | 2000-01-02 | 2000-01-01 | 2000-01-01 | 2000-01-01 | 2000-01-01
2020-01-03 | 2000-01-03 | 2000-01-03 | 2000-01-01 | 2000-01-01 | 2000-01-01
2020-01-04 | 2000-01-04 | 2000-01-03 | 2000-01-04 | 2000-01-01 | 2000-01-01
2020-01-05 | 2000-01-05 | 2000-01-05 | 2000-01-04 | 2000-01-01 | 2000-01-01
2020-01-06 | 2000-01-06 | 2000-01-05 | 2000-01-04 | 2000-01-01 | 2000-01-01
2020-01-07 | 2000-01-07 | 2000-01-07 | 2000-01-07 | 2000-01-01 | 2000-01-01
2020-01-08 | 2000-01-08 | 2000-01-07 | 2000-01-07 | 2000-01-08 | 2000-01-01
2020-01-09 | 2000-01-09 | 2000-01-09 | 2000-01-07 | 2000-01-08 | 2000-01-01
2020-01-10 | 2000-01-10 | 2000-01-09 | 2000-01-10 | 2000-01-08 | 2000-01-10
2020-01-11 | 2000-01-11 | 2000-01-11 | 2000-01-10 | 2000-01-08 | 2000-01-10
2020-01-12 | 2000-01-12 | 2000-01-11 | 2000-01-10 | 2000-01-08 | 2000-01-10
2020-01-01 | 2020-01-01 | 2020-01-01 | 2020-01-01 | 2020-01-01 | 2020-01-01
2020-01-02 | 2020-01-02 | 2020-01-01 | 2020-01-01 | 2020-01-01 | 2020-01-01
2020-01-03 | 2020-01-03 | 2020-01-03 | 2020-01-01 | 2020-01-01 | 2020-01-01
2020-01-04 | 2020-01-04 | 2020-01-03 | 2020-01-04 | 2020-01-01 | 2020-01-01
2020-01-05 | 2020-01-05 | 2020-01-05 | 2020-01-04 | 2020-01-01 | 2020-01-01
2020-01-06 | 2020-01-06 | 2020-01-05 | 2020-01-04 | 2020-01-01 | 2020-01-01
2020-01-07 | 2020-01-07 | 2020-01-07 | 2020-01-07 | 2020-01-01 | 2020-01-01
2020-01-08 | 2020-01-08 | 2020-01-07 | 2020-01-07 | 2020-01-08 | 2020-01-01
2020-01-09 | 2020-01-09 | 2020-01-09 | 2020-01-07 | 2020-01-08 | 2020-01-01
2020-01-10 | 2020-01-10 | 2020-01-09 | 2020-01-10 | 2020-01-08 | 2020-01-10
2020-01-11 | 2020-01-11 | 2020-01-11 | 2020-01-10 | 2020-01-08 | 2020-01-10
2020-01-12 | 2020-01-12 | 2020-01-11 | 2020-01-10 | 2020-01-08 | 2020-01-10
(12 rows)

-- N month buckets
Expand Down