Merge the implementation of timechart and chart#4755
Merge the implementation of timechart and chart#4755LantaoJin merged 11 commits intoopensearch-project:mainfrom
timechart and chart#4755Conversation
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
- add 2 more indicies for test purpose Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
| 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.
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.
region does not exist in the given index, therefore replaced
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
| 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.
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.
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.
why the location of option nullstr changed?
There was a problem hiding this comment.
@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.
ditto: cannot timechart span=1d limit=2 count() by host work now? can it work in spl?
There was a problem hiding this comment.
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 <yuanchu@amazon.com> * Migrate per functions to Chart Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Update CalcitePPLTimechartTest Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Migrate TimecharTest to use Chart Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Fix AST relevant tests Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Remove Timechart AST object in favor of Chart Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Update expected plans for timechart Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Update doctest for timechart - add 2 more indicies for test purpose Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Add yaml tests for 4581, 4582, and 4632 Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Allow flexible parameter positions for chart and timechart Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Simplify CalciteTimechartCommandIT Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> --------- Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> (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 <yuanchu@amazon.com>
…ct#4755) * Remove visitTimechart Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Migrate per functions to Chart Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Update CalcitePPLTimechartTest Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Migrate TimecharTest to use Chart Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Fix AST relevant tests Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Remove Timechart AST object in favor of Chart Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Update expected plans for timechart Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Update doctest for timechart - add 2 more indicies for test purpose Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Add yaml tests for 4581, 4582, and 4632 Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Allow flexible parameter positions for chart and timechart Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> * Simplify CalciteTimechartCommandIT Signed-off-by: Yuanchun Shen <yuanchu@amazon.com> --------- Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
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.