-
Notifications
You must be signed in to change notification settings - Fork 178
Merge the implementation of timechart and chart
#4755
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
Conversation
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
- add 2 more indicies for test purpose Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
Signed-off-by: Yuanchun Shen <[email protected]>
| Example 3: Calculate average number of packets by minute | ||
| ================================================ | ||
|
|
||
| This example calculates the average CPU usage for each minute without grouping by any field. |
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.
cpu_usage does not exist in the given index, therefore replaced
| Example 5: Count events by hour and category | ||
| ===================================================================== | ||
|
|
||
| This example counts events for each second and groups them by region, showing zero values for time-region combinations with no data. |
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.
region does not exist in the given index, therefore replaced
Signed-off-by: Yuanchun Shen <[email protected]>
| fetched rows / total rows = 8/8 | ||
| +---------------------+---------+---------+ | ||
| | @timestamp | host | count() | | ||
| |---------------------+---------+---------| | ||
| | 2023-01-01 10:00:00 | server1 | 1 | | ||
| | 2023-01-01 10:05:00 | server2 | 1 | | ||
| | 2023-01-01 10:10:00 | server1 | 1 | | ||
| | 2023-01-01 10:15:00 | server2 | 1 | | ||
| | 2023-01-01 10:20:00 | server1 | 1 | | ||
| | 2023-01-01 10:25:00 | server2 | 1 | | ||
| | 2023-01-01 10:30:00 | server1 | 1 | | ||
| | 2023-01-01 10:35:00 | server2 | 1 | | ||
| +---------------------+---------+---------+ | ||
|
|
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.
Why the results before and after for the same ppl query are different? please confirm the current result is correct comparing to SPL.
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.
The difference lies in whether we fill 0 for non-existing groups.
In SPL, timechart and chart will pivot the result table, explicitly filling 0 for count aggregation, leaving it empty for the rest aggregation functions. E.g. the result in SPL will be like:
@timestamp |
server1 |
server2 |
|---|---|---|
| 2023-01-01 10:00:00 | 1 | 0 |
| 2023-01-01 10:05:00 | 0 | 1 |
| 2023-01-01 10:10:00 | 1 | 0 |
| 2023-01-01 10:15:00 | 0 | 1 |
| 2023-01-01 10:20:00 | 1 | 0 |
| 2023-01-01 10:25:00 | 0 | 1 |
| 2023-01-01 10:30:00 | 1 | 0 |
| 2023-01-01 10:35:00 | 0 | 1 |
In this thread and offline discussions, we decided to not fill 0 for non-existing groups to simplify implementations and keep consistence with docs (see #4632), leaving the pivoting and zero-filling to frontend if necessary.
| "source=%s | chart usenull=false count() over gender by age " | ||
| + " span=10 nullstr='not_shown'", |
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.
why the location of option nullstr changed?
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.
@penghuo commented that it would be better if the argument positions are more flexible in #4579 (comment)
Here, I altered the location of argument nullstr to exemplify this point
|
|
||
| JSONObject result = | ||
| executeQuery("source=events_null | timechart span=1d limit=2 count() by host"); | ||
| executeQuery("source=events_null | timechart count() by host span=1d limit=2"); |
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.
ditto: cannot timechart span=1d limit=2 count() by host work now? can it work in spl?
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 works. The locations of these arguments are scattered in different locations across the ITs.
|
The backport to To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.19-dev 2.19-dev
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.19-dev
# Create a new branch
git switch --create backport/backport-4755-to-2.19-dev
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 daf1795a0672c9f6ce1d1bd74fc58415963d099a
# Push it to GitHub
git push --set-upstream origin backport/backport-4755-to-2.19-dev
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.19-devThen, create a pull request where the |
…ct#4755) * Remove visitTimechart Signed-off-by: Yuanchun Shen <[email protected]> * Migrate per functions to Chart Signed-off-by: Yuanchun Shen <[email protected]> * Update CalcitePPLTimechartTest Signed-off-by: Yuanchun Shen <[email protected]> * Migrate TimecharTest to use Chart Signed-off-by: Yuanchun Shen <[email protected]> * Fix AST relevant tests Signed-off-by: Yuanchun Shen <[email protected]> * Remove Timechart AST object in favor of Chart Signed-off-by: Yuanchun Shen <[email protected]> * Update expected plans for timechart Signed-off-by: Yuanchun Shen <[email protected]> * Update doctest for timechart - add 2 more indicies for test purpose Signed-off-by: Yuanchun Shen <[email protected]> * Add yaml tests for 4581, 4582, and 4632 Signed-off-by: Yuanchun Shen <[email protected]> * Allow flexible parameter positions for chart and timechart Signed-off-by: Yuanchun Shen <[email protected]> * Simplify CalciteTimechartCommandIT Signed-off-by: Yuanchun Shen <[email protected]> --------- Signed-off-by: Yuanchun Shen <[email protected]> (cherry picked from commit daf1795)
* Remove visitTimechart * Migrate per functions to Chart * Update CalcitePPLTimechartTest * Migrate TimecharTest to use Chart * Fix AST relevant tests * Remove Timechart AST object in favor of Chart * Update expected plans for timechart * Update doctest for timechart - add 2 more indicies for test purpose * Add yaml tests for 4581, 4582, and 4632 * Allow flexible parameter positions for chart and timechart * Simplify CalciteTimechartCommandIT --------- (cherry picked from commit daf1795) Signed-off-by: Yuanchun Shen <[email protected]>
Description
timechartis semantically a subset ofchart, where the row-split is always fixed to@timestamp. This PR merges their implementation for easier maintenance and resolves a few existing bugs oftimechart.Related Issues
Resolves #4581, resolves #4582, resolves #4632
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.