-
Notifications
You must be signed in to change notification settings - Fork 181
Support timechart command with Calcite #3993
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
Support timechart command with Calcite #3993
Conversation
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
aabad00 to
4544e80
Compare
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
core/src/main/java/org/opensearch/sql/calcite/CalcitePlanContext.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/calcite/utils/PlanUtils.java
Outdated
Show resolved
Hide resolved
|
|
||
| // Handle no by field case | ||
| if (node.getByField() == null) { | ||
| String valueFunctionName = getValueFunctionName(node.getAggregateFunction()); |
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.
sql/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstBuilder.java
Lines 612 to 617 in 98c1b6a
| /** Get original text in query. */ | |
| private String getTextInQuery(ParserRuleContext ctx) { | |
| Token start = ctx.getStart(); | |
| Token stop = ctx.getStop(); | |
| return query.substring(start.getStartIndex(), stop.getStopIndex() + 1); | |
| } |
For stats command, the name is generated directly from the query text when building AST. Maybe we should do similar thing in visitTimechartCommand.
|
|
||
| @Test | ||
| public void testExplainWithTimechart() throws IOException { | ||
| var result = explainQueryToString("source=events | timechart span=1m avg(cpu_usage) by host"); |
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.
// Use zero-filling for count aggregations, standard result for others
Please add explain test case for count aggregation as it gets a totally different plan actually.
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
| // First rename the timestamp field (2nd to last) to @timestamp | ||
| List<String> fieldNames = context.relBuilder.peek().getRowType().getFieldNames(); | ||
| List<String> renamedFields = new ArrayList<>(fieldNames); | ||
| renamedFields.set(fieldNames.size() - 2, "@timestamp"); |
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 reason why we find that there is flip for group by keys is because of the registry mechanism for aggregate key in Calcite.
It's actually not flip but appending new expressions(i.e. span(...) here) to the original expressions. So although we constructed group by expr to be [spanExpr, byField], but got [byField, spanExpr] in the end.
ppl/src/test/java/org/opensearch/sql/ppl/calcite/CalcitePPLTimechartTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
Signed-off-by: Selina Song <selsong@amazon.com>
penghuo
left a comment
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 @selsong!
Let's track performance issue separately.
qianheng-aws
left a comment
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 functionality of this PR LGTM. Thanks for your contribution! @selsong
|
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-3993-to-2.19-dev
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 e2678a13fc9a6acc7bfced322e3cc2156a8dec91
# Push it to GitHub
git push --set-upstream origin backport/backport-3993-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 |
* WIP: Support timechart grammar / AST Signed-off-by: Selina Song <selsong@amazon.com> * WIP: Support span=unit in timechart Signed-off-by: Selina Song <selsong@amazon.com> * Return correct column format after span=unit Signed-off-by: Selina Song <selsong@amazon.com> * sort by @timestamp, group by aggregate function Signed-off-by: Selina Song <selsong@amazon.com> * WIP: pivot table by field Signed-off-by: Selina Song <selsong@amazon.com> * Correct pivot format for by field Signed-off-by: Selina Song <selsong@amazon.com> * Fix aggregation composite bucket limit Signed-off-by: Selina Song <selsong@amazon.com> * Add timechart.rst doc and PPLQueryAnonymizer test Signed-off-by: Selina Song <selsong@amazon.com> * Add ExplainIT for timechart Signed-off-by: Selina Song <selsong@amazon.com> * Restore reverse ExplainIT Signed-off-by: Selina Song <selsong@amazon.com> * Update explainIT timechart Signed-off-by: Selina Song <selsong@amazon.com> * spotlessApply formatting Signed-off-by: Selina Song <selsong@amazon.com> * format IT Signed-off-by: Selina Song <selsong@amazon.com> * Add limit parameter Signed-off-by: Selina Song <selsong@amazon.com> * Add limit=0 means no limit, show all values, no other Signed-off-by: Selina Song <selsong@amazon.com> * Add useother parameter Signed-off-by: Selina Song <selsong@amazon.com> * clean up format, fix column order Signed-off-by: Selina Song <selsong@amazon.com> * add test for formatter Signed-off-by: Selina Song <selsong@amazon.com> * Increase test coverage for formatter Signed-off-by: Selina Song <selsong@amazon.com> * Rename bin option expression, modify constructor Signed-off-by: Selina Song <selsong@amazon.com> * Make test data smaller, update IT, rst Signed-off-by: Selina Song <selsong@amazon.com> * add explain output to IT Signed-off-by: Selina Song <selsong@amazon.com> * Add limitation to rst, format, comment Signed-off-by: Selina Song <selsong@amazon.com> * Add test coverage formatter Signed-off-by: Selina Song <selsong@amazon.com> * Refactor formatter for clarity Signed-off-by: Selina Song <selsong@amazon.com> * fix NPE Signed-off-by: Selina Song <selsong@amazon.com> * add import Signed-off-by: Selina Song <selsong@amazon.com> * update mapping to match smaller dataset Signed-off-by: Selina Song <selsong@amazon.com> * update explainIT Signed-off-by: Selina Song <selsong@amazon.com> * Fix explainIT, improve code structure Signed-off-by: Selina Song <selsong@amazon.com> * spotless Signed-off-by: Selina Song <selsong@amazon.com> * Support diff position parameters, count default 0 not null, update doc rst Signed-off-by: Selina Song <selsong@amazon.com> * fix count aggr type int Signed-off-by: Selina Song <selsong@amazon.com> * rename @timestamp column Signed-off-by: Selina Song <selsong@amazon.com> * move parameter extraction to PPLService Signed-off-by: Selina Song <selsong@amazon.com> * clean up PPLService Signed-off-by: Selina Song <selsong@amazon.com> * fix count type test, doc rst format Signed-off-by: Selina Song <selsong@amazon.com> * add test coverage Signed-off-by: Selina Song <selsong@amazon.com> * WIP: SQL query with limit useother Signed-off-by: Selina Song <selsong@amazon.com> * revert QueryService Signed-off-by: Selina Song <selsong@amazon.com> * add limit useother to SQL query Signed-off-by: Selina Song <selsong@amazon.com> * SQL query working, WIP column rename Signed-off-by: Selina Song <selsong@amazon.com> * use loadIndex in IT Signed-off-by: Selina Song <selsong@amazon.com> * Rename fields to match, update doc Signed-off-by: Selina Song <selsong@amazon.com> * revert QueryResult Signed-off-by: Selina Song <selsong@amazon.com> * revert gradle build Signed-off-by: Selina Song <selsong@amazon.com> * fix format Signed-off-by: Selina Song <selsong@amazon.com> * Add count fill zero, update toSQL tests, doc Signed-off-by: Selina Song <selsong@amazon.com> * fix nits Signed-off-by: Selina Song <selsong@amazon.com> * Fix rename aggregation only no by field Signed-off-by: Selina Song <selsong@amazon.com> * Update SQL test Signed-off-by: Selina Song <selsong@amazon.com> * revert OS Exec Engine edits Signed-off-by: Selina Song <selsong@amazon.com> * correct OS Exec Engine revert to 5ec9603 Signed-off-by: Selina Song <selsong@amazon.com> * restore OS Exec Engine Signed-off-by: Selina Song <selsong@amazon.com> * update QueryAnonymizer Test to reflect default Signed-off-by: Selina Song <selsong@amazon.com> * WIP: Add null=1, Other fill zero wip Signed-off-by: Selina Song <selsong@amazon.com> * Add doctest and update ExplainIT Signed-off-by: Selina Song <selsong@amazon.com> * Replace detectFieldIndices function Signed-off-by: Selina Song <selsong@amazon.com> * update explainIT Signed-off-by: Selina Song <selsong@amazon.com> * Fix Other in zero fill case Signed-off-by: Selina Song <selsong@amazon.com> * Fix OTHER in zero fill case Signed-off-by: Selina Song <selsong@amazon.com> * spotless format Signed-off-by: Selina Song <selsong@amazon.com> * update doc with null example Signed-off-by: Selina Song <selsong@amazon.com> * null not included in limit calc Signed-off-by: Selina Song <selsong@amazon.com> * update SQL test Signed-off-by: Selina Song <selsong@amazon.com> * update SQL test format Signed-off-by: Selina Song <selsong@amazon.com> * Update ExplainIT with count Signed-off-by: Selina Song <selsong@amazon.com> * remove unused code Signed-off-by: Selina Song <selsong@amazon.com> * Fix SQL tests nullable Signed-off-by: Selina Song <selsong@amazon.com> * spotless format Signed-off-by: Selina Song <selsong@amazon.com> --------- Signed-off-by: Selina Song <selsong@amazon.com> Signed-off-by: Selina Song <selinasong6@gmail.com> Co-authored-by: Selina Song <selsong@amazon.com> (cherry picked from commit e2678a1)
* WIP: Support timechart grammar / AST Signed-off-by: Selina Song <selsong@amazon.com> * WIP: Support span=unit in timechart Signed-off-by: Selina Song <selsong@amazon.com> * Return correct column format after span=unit Signed-off-by: Selina Song <selsong@amazon.com> * sort by @timestamp, group by aggregate function Signed-off-by: Selina Song <selsong@amazon.com> * WIP: pivot table by field Signed-off-by: Selina Song <selsong@amazon.com> * Correct pivot format for by field Signed-off-by: Selina Song <selsong@amazon.com> * Fix aggregation composite bucket limit Signed-off-by: Selina Song <selsong@amazon.com> * Add timechart.rst doc and PPLQueryAnonymizer test Signed-off-by: Selina Song <selsong@amazon.com> * Add ExplainIT for timechart Signed-off-by: Selina Song <selsong@amazon.com> * Restore reverse ExplainIT Signed-off-by: Selina Song <selsong@amazon.com> * Update explainIT timechart Signed-off-by: Selina Song <selsong@amazon.com> * spotlessApply formatting Signed-off-by: Selina Song <selsong@amazon.com> * format IT Signed-off-by: Selina Song <selsong@amazon.com> * Add limit parameter Signed-off-by: Selina Song <selsong@amazon.com> * Add limit=0 means no limit, show all values, no other Signed-off-by: Selina Song <selsong@amazon.com> * Add useother parameter Signed-off-by: Selina Song <selsong@amazon.com> * clean up format, fix column order Signed-off-by: Selina Song <selsong@amazon.com> * add test for formatter Signed-off-by: Selina Song <selsong@amazon.com> * Increase test coverage for formatter Signed-off-by: Selina Song <selsong@amazon.com> * Rename bin option expression, modify constructor Signed-off-by: Selina Song <selsong@amazon.com> * Make test data smaller, update IT, rst Signed-off-by: Selina Song <selsong@amazon.com> * add explain output to IT Signed-off-by: Selina Song <selsong@amazon.com> * Add limitation to rst, format, comment Signed-off-by: Selina Song <selsong@amazon.com> * Add test coverage formatter Signed-off-by: Selina Song <selsong@amazon.com> * Refactor formatter for clarity Signed-off-by: Selina Song <selsong@amazon.com> * fix NPE Signed-off-by: Selina Song <selsong@amazon.com> * add import Signed-off-by: Selina Song <selsong@amazon.com> * update mapping to match smaller dataset Signed-off-by: Selina Song <selsong@amazon.com> * update explainIT Signed-off-by: Selina Song <selsong@amazon.com> * Fix explainIT, improve code structure Signed-off-by: Selina Song <selsong@amazon.com> * spotless Signed-off-by: Selina Song <selsong@amazon.com> * Support diff position parameters, count default 0 not null, update doc rst Signed-off-by: Selina Song <selsong@amazon.com> * fix count aggr type int Signed-off-by: Selina Song <selsong@amazon.com> * rename @timestamp column Signed-off-by: Selina Song <selsong@amazon.com> * move parameter extraction to PPLService Signed-off-by: Selina Song <selsong@amazon.com> * clean up PPLService Signed-off-by: Selina Song <selsong@amazon.com> * fix count type test, doc rst format Signed-off-by: Selina Song <selsong@amazon.com> * add test coverage Signed-off-by: Selina Song <selsong@amazon.com> * WIP: SQL query with limit useother Signed-off-by: Selina Song <selsong@amazon.com> * revert QueryService Signed-off-by: Selina Song <selsong@amazon.com> * add limit useother to SQL query Signed-off-by: Selina Song <selsong@amazon.com> * SQL query working, WIP column rename Signed-off-by: Selina Song <selsong@amazon.com> * use loadIndex in IT Signed-off-by: Selina Song <selsong@amazon.com> * Rename fields to match, update doc Signed-off-by: Selina Song <selsong@amazon.com> * revert QueryResult Signed-off-by: Selina Song <selsong@amazon.com> * revert gradle build Signed-off-by: Selina Song <selsong@amazon.com> * fix format Signed-off-by: Selina Song <selsong@amazon.com> * Add count fill zero, update toSQL tests, doc Signed-off-by: Selina Song <selsong@amazon.com> * fix nits Signed-off-by: Selina Song <selsong@amazon.com> * Fix rename aggregation only no by field Signed-off-by: Selina Song <selsong@amazon.com> * Update SQL test Signed-off-by: Selina Song <selsong@amazon.com> * revert OS Exec Engine edits Signed-off-by: Selina Song <selsong@amazon.com> * correct OS Exec Engine revert to 5ec9603 Signed-off-by: Selina Song <selsong@amazon.com> * restore OS Exec Engine Signed-off-by: Selina Song <selsong@amazon.com> * update QueryAnonymizer Test to reflect default Signed-off-by: Selina Song <selsong@amazon.com> * WIP: Add null=1, Other fill zero wip Signed-off-by: Selina Song <selsong@amazon.com> * Add doctest and update ExplainIT Signed-off-by: Selina Song <selsong@amazon.com> * Replace detectFieldIndices function Signed-off-by: Selina Song <selsong@amazon.com> * update explainIT Signed-off-by: Selina Song <selsong@amazon.com> * Fix Other in zero fill case Signed-off-by: Selina Song <selsong@amazon.com> * Fix OTHER in zero fill case Signed-off-by: Selina Song <selsong@amazon.com> * spotless format Signed-off-by: Selina Song <selsong@amazon.com> * update doc with null example Signed-off-by: Selina Song <selsong@amazon.com> * null not included in limit calc Signed-off-by: Selina Song <selsong@amazon.com> * update SQL test Signed-off-by: Selina Song <selsong@amazon.com> * update SQL test format Signed-off-by: Selina Song <selsong@amazon.com> * Update ExplainIT with count Signed-off-by: Selina Song <selsong@amazon.com> * remove unused code Signed-off-by: Selina Song <selsong@amazon.com> * Fix SQL tests nullable Signed-off-by: Selina Song <selsong@amazon.com> * spotless format Signed-off-by: Selina Song <selsong@amazon.com> --------- Signed-off-by: Selina Song <selsong@amazon.com> Signed-off-by: Selina Song <selinasong6@gmail.com> Co-authored-by: Selina Song <selsong@amazon.com> (cherry picked from commit e2678a1)
* WIP: Support timechart grammar / AST Signed-off-by: Selina Song <selsong@amazon.com> * WIP: Support span=unit in timechart Signed-off-by: Selina Song <selsong@amazon.com> * Return correct column format after span=unit Signed-off-by: Selina Song <selsong@amazon.com> * sort by @timestamp, group by aggregate function Signed-off-by: Selina Song <selsong@amazon.com> * WIP: pivot table by field Signed-off-by: Selina Song <selsong@amazon.com> * Correct pivot format for by field Signed-off-by: Selina Song <selsong@amazon.com> * Fix aggregation composite bucket limit Signed-off-by: Selina Song <selsong@amazon.com> * Add timechart.rst doc and PPLQueryAnonymizer test Signed-off-by: Selina Song <selsong@amazon.com> * Add ExplainIT for timechart Signed-off-by: Selina Song <selsong@amazon.com> * Restore reverse ExplainIT Signed-off-by: Selina Song <selsong@amazon.com> * Update explainIT timechart Signed-off-by: Selina Song <selsong@amazon.com> * spotlessApply formatting Signed-off-by: Selina Song <selsong@amazon.com> * format IT Signed-off-by: Selina Song <selsong@amazon.com> * Add limit parameter Signed-off-by: Selina Song <selsong@amazon.com> * Add limit=0 means no limit, show all values, no other Signed-off-by: Selina Song <selsong@amazon.com> * Add useother parameter Signed-off-by: Selina Song <selsong@amazon.com> * clean up format, fix column order Signed-off-by: Selina Song <selsong@amazon.com> * add test for formatter Signed-off-by: Selina Song <selsong@amazon.com> * Increase test coverage for formatter Signed-off-by: Selina Song <selsong@amazon.com> * Rename bin option expression, modify constructor Signed-off-by: Selina Song <selsong@amazon.com> * Make test data smaller, update IT, rst Signed-off-by: Selina Song <selsong@amazon.com> * add explain output to IT Signed-off-by: Selina Song <selsong@amazon.com> * Add limitation to rst, format, comment Signed-off-by: Selina Song <selsong@amazon.com> * Add test coverage formatter Signed-off-by: Selina Song <selsong@amazon.com> * Refactor formatter for clarity Signed-off-by: Selina Song <selsong@amazon.com> * fix NPE Signed-off-by: Selina Song <selsong@amazon.com> * add import Signed-off-by: Selina Song <selsong@amazon.com> * update mapping to match smaller dataset Signed-off-by: Selina Song <selsong@amazon.com> * update explainIT Signed-off-by: Selina Song <selsong@amazon.com> * Fix explainIT, improve code structure Signed-off-by: Selina Song <selsong@amazon.com> * spotless Signed-off-by: Selina Song <selsong@amazon.com> * Support diff position parameters, count default 0 not null, update doc rst Signed-off-by: Selina Song <selsong@amazon.com> * fix count aggr type int Signed-off-by: Selina Song <selsong@amazon.com> * rename @timestamp column Signed-off-by: Selina Song <selsong@amazon.com> * move parameter extraction to PPLService Signed-off-by: Selina Song <selsong@amazon.com> * clean up PPLService Signed-off-by: Selina Song <selsong@amazon.com> * fix count type test, doc rst format Signed-off-by: Selina Song <selsong@amazon.com> * add test coverage Signed-off-by: Selina Song <selsong@amazon.com> * WIP: SQL query with limit useother Signed-off-by: Selina Song <selsong@amazon.com> * revert QueryService Signed-off-by: Selina Song <selsong@amazon.com> * add limit useother to SQL query Signed-off-by: Selina Song <selsong@amazon.com> * SQL query working, WIP column rename Signed-off-by: Selina Song <selsong@amazon.com> * use loadIndex in IT Signed-off-by: Selina Song <selsong@amazon.com> * Rename fields to match, update doc Signed-off-by: Selina Song <selsong@amazon.com> * revert QueryResult Signed-off-by: Selina Song <selsong@amazon.com> * revert gradle build Signed-off-by: Selina Song <selsong@amazon.com> * fix format Signed-off-by: Selina Song <selsong@amazon.com> * Add count fill zero, update toSQL tests, doc Signed-off-by: Selina Song <selsong@amazon.com> * fix nits Signed-off-by: Selina Song <selsong@amazon.com> * Fix rename aggregation only no by field Signed-off-by: Selina Song <selsong@amazon.com> * Update SQL test Signed-off-by: Selina Song <selsong@amazon.com> * revert OS Exec Engine edits Signed-off-by: Selina Song <selsong@amazon.com> * correct OS Exec Engine revert to 5ec9603 Signed-off-by: Selina Song <selsong@amazon.com> * restore OS Exec Engine Signed-off-by: Selina Song <selsong@amazon.com> * update QueryAnonymizer Test to reflect default Signed-off-by: Selina Song <selsong@amazon.com> * WIP: Add null=1, Other fill zero wip Signed-off-by: Selina Song <selsong@amazon.com> * Add doctest and update ExplainIT Signed-off-by: Selina Song <selsong@amazon.com> * Replace detectFieldIndices function Signed-off-by: Selina Song <selsong@amazon.com> * update explainIT Signed-off-by: Selina Song <selsong@amazon.com> * Fix Other in zero fill case Signed-off-by: Selina Song <selsong@amazon.com> * Fix OTHER in zero fill case Signed-off-by: Selina Song <selsong@amazon.com> * spotless format Signed-off-by: Selina Song <selsong@amazon.com> * update doc with null example Signed-off-by: Selina Song <selsong@amazon.com> * null not included in limit calc Signed-off-by: Selina Song <selsong@amazon.com> * update SQL test Signed-off-by: Selina Song <selsong@amazon.com> * update SQL test format Signed-off-by: Selina Song <selsong@amazon.com> * Update ExplainIT with count Signed-off-by: Selina Song <selsong@amazon.com> * remove unused code Signed-off-by: Selina Song <selsong@amazon.com> * Fix SQL tests nullable Signed-off-by: Selina Song <selsong@amazon.com> * spotless format Signed-off-by: Selina Song <selsong@amazon.com> --------- Signed-off-by: Selina Song <selsong@amazon.com> Signed-off-by: Selina Song <selinasong6@gmail.com> Co-authored-by: Selina Song <selsong@amazon.com> (cherry picked from commit e2678a1)
…4232) * Support timechart command with Calcite (#3993) * WIP: Support timechart grammar / AST Signed-off-by: Selina Song <selsong@amazon.com> * WIP: Support span=unit in timechart Signed-off-by: Selina Song <selsong@amazon.com> * Return correct column format after span=unit Signed-off-by: Selina Song <selsong@amazon.com> * sort by @timestamp, group by aggregate function Signed-off-by: Selina Song <selsong@amazon.com> * WIP: pivot table by field Signed-off-by: Selina Song <selsong@amazon.com> * Correct pivot format for by field Signed-off-by: Selina Song <selsong@amazon.com> * Fix aggregation composite bucket limit Signed-off-by: Selina Song <selsong@amazon.com> * Add timechart.rst doc and PPLQueryAnonymizer test Signed-off-by: Selina Song <selsong@amazon.com> * Add ExplainIT for timechart Signed-off-by: Selina Song <selsong@amazon.com> * Restore reverse ExplainIT Signed-off-by: Selina Song <selsong@amazon.com> * Update explainIT timechart Signed-off-by: Selina Song <selsong@amazon.com> * spotlessApply formatting Signed-off-by: Selina Song <selsong@amazon.com> * format IT Signed-off-by: Selina Song <selsong@amazon.com> * Add limit parameter Signed-off-by: Selina Song <selsong@amazon.com> * Add limit=0 means no limit, show all values, no other Signed-off-by: Selina Song <selsong@amazon.com> * Add useother parameter Signed-off-by: Selina Song <selsong@amazon.com> * clean up format, fix column order Signed-off-by: Selina Song <selsong@amazon.com> * add test for formatter Signed-off-by: Selina Song <selsong@amazon.com> * Increase test coverage for formatter Signed-off-by: Selina Song <selsong@amazon.com> * Rename bin option expression, modify constructor Signed-off-by: Selina Song <selsong@amazon.com> * Make test data smaller, update IT, rst Signed-off-by: Selina Song <selsong@amazon.com> * add explain output to IT Signed-off-by: Selina Song <selsong@amazon.com> * Add limitation to rst, format, comment Signed-off-by: Selina Song <selsong@amazon.com> * Add test coverage formatter Signed-off-by: Selina Song <selsong@amazon.com> * Refactor formatter for clarity Signed-off-by: Selina Song <selsong@amazon.com> * fix NPE Signed-off-by: Selina Song <selsong@amazon.com> * add import Signed-off-by: Selina Song <selsong@amazon.com> * update mapping to match smaller dataset Signed-off-by: Selina Song <selsong@amazon.com> * update explainIT Signed-off-by: Selina Song <selsong@amazon.com> * Fix explainIT, improve code structure Signed-off-by: Selina Song <selsong@amazon.com> * spotless Signed-off-by: Selina Song <selsong@amazon.com> * Support diff position parameters, count default 0 not null, update doc rst Signed-off-by: Selina Song <selsong@amazon.com> * fix count aggr type int Signed-off-by: Selina Song <selsong@amazon.com> * rename @timestamp column Signed-off-by: Selina Song <selsong@amazon.com> * move parameter extraction to PPLService Signed-off-by: Selina Song <selsong@amazon.com> * clean up PPLService Signed-off-by: Selina Song <selsong@amazon.com> * fix count type test, doc rst format Signed-off-by: Selina Song <selsong@amazon.com> * add test coverage Signed-off-by: Selina Song <selsong@amazon.com> * WIP: SQL query with limit useother Signed-off-by: Selina Song <selsong@amazon.com> * revert QueryService Signed-off-by: Selina Song <selsong@amazon.com> * add limit useother to SQL query Signed-off-by: Selina Song <selsong@amazon.com> * SQL query working, WIP column rename Signed-off-by: Selina Song <selsong@amazon.com> * use loadIndex in IT Signed-off-by: Selina Song <selsong@amazon.com> * Rename fields to match, update doc Signed-off-by: Selina Song <selsong@amazon.com> * revert QueryResult Signed-off-by: Selina Song <selsong@amazon.com> * revert gradle build Signed-off-by: Selina Song <selsong@amazon.com> * fix format Signed-off-by: Selina Song <selsong@amazon.com> * Add count fill zero, update toSQL tests, doc Signed-off-by: Selina Song <selsong@amazon.com> * fix nits Signed-off-by: Selina Song <selsong@amazon.com> * Fix rename aggregation only no by field Signed-off-by: Selina Song <selsong@amazon.com> * Update SQL test Signed-off-by: Selina Song <selsong@amazon.com> * revert OS Exec Engine edits Signed-off-by: Selina Song <selsong@amazon.com> * correct OS Exec Engine revert to 5ec9603 Signed-off-by: Selina Song <selsong@amazon.com> * restore OS Exec Engine Signed-off-by: Selina Song <selsong@amazon.com> * update QueryAnonymizer Test to reflect default Signed-off-by: Selina Song <selsong@amazon.com> * WIP: Add null=1, Other fill zero wip Signed-off-by: Selina Song <selsong@amazon.com> * Add doctest and update ExplainIT Signed-off-by: Selina Song <selsong@amazon.com> * Replace detectFieldIndices function Signed-off-by: Selina Song <selsong@amazon.com> * update explainIT Signed-off-by: Selina Song <selsong@amazon.com> * Fix Other in zero fill case Signed-off-by: Selina Song <selsong@amazon.com> * Fix OTHER in zero fill case Signed-off-by: Selina Song <selsong@amazon.com> * spotless format Signed-off-by: Selina Song <selsong@amazon.com> * update doc with null example Signed-off-by: Selina Song <selsong@amazon.com> * null not included in limit calc Signed-off-by: Selina Song <selsong@amazon.com> * update SQL test Signed-off-by: Selina Song <selsong@amazon.com> * update SQL test format Signed-off-by: Selina Song <selsong@amazon.com> * Update ExplainIT with count Signed-off-by: Selina Song <selsong@amazon.com> * remove unused code Signed-off-by: Selina Song <selsong@amazon.com> * Fix SQL tests nullable Signed-off-by: Selina Song <selsong@amazon.com> * spotless format Signed-off-by: Selina Song <selsong@amazon.com> --------- Signed-off-by: Selina Song <selsong@amazon.com> Signed-off-by: Selina Song <selinasong6@gmail.com> Co-authored-by: Selina Song <selsong@amazon.com> (cherry picked from commit e2678a1) * restore parser Signed-off-by: Selina Song <selsong@amazon.com> --------- Signed-off-by: Selina Song <selsong@amazon.com> Signed-off-by: Selina Song <selinasong6@gmail.com> Co-authored-by: Selina Song <selsong@amazon.com>
Description
Implement timechart in PPL to accept aggregation
spanlogic and aggregation functions. This includes support for parameters such asspan,limit,useother, a single aggregation function, by field. This does not include pivot formatting.Time Binning
Limitations: (to be resolved in follow up PR)
binsparameter and other bin options are not supported since thebincommand is not implemented yet.Related Issues
Resolves #3965
1. single aggregation function
Query:
Result:
Logical Plan:
Physical Plan:
2. aggregation with by field
Query:
Result:
Logical Plan:
Physical Plan:
3.
spanparameterQuery:
Result:
Logical Plan:
Physical Plan:
4. Default
limit= 10 anduseother= trueFor by fields with more than 10 values, timechart will automatically group the extra values into an OTHER field.
Query:
Result:
Logical Plan:
Physical Plan:
5.
limitparameterQuery:
Lowest sum of aggregation function results are grouped into the OTHER column so only top 3 hosts by avg(response_time) are shown, displayed in their original order.
Result:
Logical Plan:
Physical Plan:
6.
useotherparameterQuery:
Accepts useother=t, f, true, or false. Default limit of 10 is applied since no limit is specified, but OTHER column is omitted since useother is set to false.
Result:
Logical Plan:
Physical Plan:
Performance with Big5 Testing
(span=1h, 1m, 1s, avg metrics.size, count by cloud.region)
(span=1h, 1m, 1s and count by cloud.region)
(includes spans 1s, 1m, 1h count queries)
Head 10: 64 ms
Head 100: 75 ms
Head 1 000: 113 ms
Head 10 000: Avg = 628 ms (p90 ≈ 630 ms)
For both queries:
Check List
--signoff.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.