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 wrong origin returned by cagg_get_bucket_function_info #7533

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fabriziomello
Copy link
Contributor

@fabriziomello fabriziomello commented Dec 12, 2024

In #7042 we refactored the code for getting the time bucket function info to read information from the stored query tree on Postgres metadata.

But when an origin was not specified it was returning a wrong value instead of NULL. Fixed it by properly dealing with non-defined origin and also simplified a bit the code to process time bucket parameters.

Disable-check: force-changelog-file

@fabriziomello fabriziomello self-assigned this Dec 12, 2024
@fabriziomello fabriziomello changed the title Fix origin on cagg_get_bucket_function_info Fix wrong origin returned by cagg_get_bucket_function_info Dec 12, 2024
@fabriziomello fabriziomello force-pushed the fix_origin_on_cagg_get_bucket_function_info branch from 443d35b to 9270501 Compare December 12, 2024 22:46
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.

Project coverage is 81.24%. Comparing base (59f50f2) to head (1b66597).
Report is 652 commits behind head on main.

Files with missing lines Patch % Lines
tsl/src/continuous_aggs/common.c 88.23% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7533      +/-   ##
==========================================
+ Coverage   80.06%   81.24%   +1.17%     
==========================================
  Files         190      230      +40     
  Lines       37181    43034    +5853     
  Branches     9450    10764    +1314     
==========================================
+ Hits        29770    34964    +5194     
- Misses       2997     3713     +716     
+ Partials     4414     4357      -57     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@antekresic antekresic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general, left a question about readability and setting the right expectations in the code.

* - time_bucket(width INTERVAL, ts TIMESTAMPTZ, timezone TEXT, origin TIMESTAMPTZ,
* offset INTERVAL)
*/
if (nargs >= 4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make it explicit that there can only be 3 or 5 arguments? I'd move this into a single check expecting exactly 5 arguments since 4 arguments should not happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But FuncExpr arguments is not aligned with the actual function signature, for example this function call: time_bucket('1 hour', ts, timezone=>'America/Sao_Paulo', offset=>'1 day') is actually the 5 arguments time bucket but FuncExpr has 4 arguments (FuncExpr->args). The logic to decide what to do with arguments is on process_additional_timebucket_parameter.

In timescale#7042 we refactored the code for getting the time bucket function
info to read information from the stored query tree on Postgres
metadata.

But when an origin was not specified it was returning a wrong value
instead of NULL. Fixed it by properly dealing with non-defined origin
and also simplified a bit the code to process time bucket parameters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants