-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: 1414: Adds time_bucket() support for duckdb fdw #32
Conversation
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
I am actually going to natively make this supported by Postgres. Will let you know when the PR is ready again. |
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Just need to add some more tests and implement the offsets/origin but currently the date and time base time_bucket() functions are working with postgres + duckdb. TIL that in order to debug pg extensions you need to attach to the running PID of postgres 😅 |
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Through some edge-case testing I realized that my implementation was not working as expected. I went through a few iterations locally but ultimately implemented the following calculation which when used against my edge cases is working correctly.
This will truncate the chunk of time to make it divisible by the interval. Whatever the result is will be the time bucket (in epoch seconds) that then gets converted to a regular PG timestamp or date. Currently my Timestamp implementation supports UTC timestamps. I will be creating another function using the PG type Sorry this is taking a bit longer then expected 😅 It appears to be more complex then I initially though. I will also be writing more tests for this specifically for the postgres UDF. I personally am a big fan of writing more tests then actual feature code 😆. |
Signed-off-by: Devan <[email protected]>
Appreciate the thoroughness and the tests, you're doing great. Tagging @od0 who requested the feature in the first place to check the logic |
Signed-off-by: Devan <[email protected]>
…into feat/time-bucket
@rebasedming thanks for taking a look :) -- will address everything later tonight or tomorrow morning 👍 UPDATE: Changes have been made |
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
Signed-off-by: Devan <[email protected]>
…into feat/time-bucket
Signed-off-by: Devan <[email protected]>
@rebasedming do you know if anyone is working on fixing the failing test in dev? taking a look at the CI the test that is failing is not associated with this PR. |
Awesome I see it was fixed :) |
We reverted the faulty PR, sorry about that! And apologies for the silence here, we've been slammed on some search work for a customer, but we'll get back to reviewing analytics PRs very soon! |
hey @devanbenz awesome work on this! just built and tested from your branch. works great from what I can see, with one caveat – when applying a e.g. using a subquery seems to work fine as a workaround |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This successfully adds time_bucket().
We can merge this and open a follow-up perf/bug ticket to improve LIMIT related scans.
Signed-off-by: Devan [email protected]# Ticket(s) Closed
What
time_bucket
time series data function found within DuckDB: https://duckdb.org/docs/sql/functions/date.html#time_bucketbucket_width-date-offsetTests
test_time_bucket_minutes -> tests for aggregating by minutes/timestamps
test_time_bucket_years -> tests for aggregating by date
test_time_bucket_fallback -> test to ensure that when used on a postgres table it falls back (there is currently no functioning UDF this is only working with duckdb FDW)