-
Couldn't load subscription status.
- Fork 176
Fix timechart OTHER category aggregation for non-cumulative functions #4594
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
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, please resolve the conflict.
| context.relBuilder.sort(context.relBuilder.desc(context.relBuilder.field("grand_total"))); | ||
| RexNode sortField = context.relBuilder.field("grand_total"); | ||
| sortField = | ||
| aggFunction == BuiltinFunctionName.MIN ? sortField : context.relBuilder.desc(sortField); |
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.
What's the reason of handling MIN separately? Will it meet our expected behavior?
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.
It is because limit is supposed to keep top categories, yet the expectation for top categories varies with the actual aggregation function -- for MIN and EARLIEST, the smallest ones are supposed to be of the top categories, while for most of the rest aggregations (SUM, MAX, AVG, COUNT, etc), the greatest ones are.
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
|
|
||
| /** Helper method to get the function name for proper column naming */ | ||
| private String getValueFunctionName(UnresolvedExpression aggregateFunction) { | ||
| private String getAggFieldAlias(UnresolvedExpression aggregateFunction) { |
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.
getAggFieldAlias lacks precision. How about change to getMeasureAlias?
count(balance) as cnt
balance: aggregate Field
count(): aggregate function
count(balance): measure
cnt: alias of measure
Do not forget to update the java doc either.
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.
Thanks for pointing out! I updated the name as getMetricAlias as metric conforms to how it is named in other parts of the codebase.
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
… was introduced by other PRs that interferes the earliest function or the representation of timestamp Signed-off-by: Yuanchun Shen <[email protected]>
Description
The
timechartcommand withlimitparameter was incorrectly handling non-cumulative aggregations (max, min, earliest, latest, etc) in the "OTHER" category. Instead of applying the proper aggregation function, it was incorrectly summing all values from categories that exceeded the limit.Example:
source=index | timechart limit=1 span=1d max(severityNumber) by severityTextmax(severityNumber) = 23(the actual maximum value)max(severityNumber) = 276(sum of all values)Root Cause
The timechart implementation made an incorrect assumption that all aggregations are cumulative (like sum/count). For non-cumulative functions like max, min, earliest, and latest, the "OTHER" category should apply the same aggregation function rather than summing the values.
Solution
Limitation:
TAKE,STDDEV_SAMP, although the use case of them in timechart is rare.Related Issues
Resolves #4582
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.