-
Notifications
You must be signed in to change notification settings - Fork 197
Feature: PPL command - WMA Trendline #3293
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
Changes from 28 commits
927fbfa
3836f31
0fcd688
898d3a6
ab58370
51d8395
e4c25b3
f6c82ae
d0cf898
ce94ca9
f32e5ad
4d95529
df3c666
3ed8fa8
7fc4075
3b7902f
47f9cec
b8cf496
4a56b57
0b50637
b8e3983
8dc96c9
c197ecd
5ea47ae
8d6ac31
9ce1d99
bdb0f28
fa685bd
b87db9f
39bf113
ba9bfb6
9910b22
4be0400
8348950
6037742
e590fb9
eccbf1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,4 +75,68 @@ public void testTrendlineWithSort() throws IOException { | |
| TEST_INDEX_BANK)); | ||
| verifyDataRows(result, rows(new Object[] {null}), rows(44313.0), rows(39882.5)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testTrendlineWma() throws IOException { | ||
| final JSONObject result = | ||
| executeQuery( | ||
| String.format( | ||
| "source=%s | where balance > 39000 | sort balance | trendline wma(2, balance) as" | ||
| + " balance_trend | fields balance_trend", | ||
| TEST_INDEX_BANK)); | ||
| verifyDataRows( | ||
| result, rows(new Object[] {null}), rows(45570.666666666664), rows(40101.666666666664)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testTrendlineMultipleFieldsWma() throws IOException { | ||
| final JSONObject result = | ||
| executeQuery( | ||
| String.format( | ||
| "source=%s | where balance > 39000 | sort balance | trendline wma(2, balance) as" | ||
| + " balance_trend wma(2, account_number) as account_number_trend | fields" | ||
| + " balance_trend, account_number_trend", | ||
| TEST_INDEX_BANK)); | ||
| verifyDataRows( | ||
| result, | ||
| rows(null, null), | ||
| rows(40101.666666666664, 16.999999999999996), | ||
| rows(45570.666666666664, 29.666666666666664)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testTrendlineOverwritesExistingFieldWma() throws IOException { | ||
| final JSONObject result = | ||
| executeQuery( | ||
| String.format( | ||
| "source=%s | where balance > 39000 | sort balance | trendline wma(2, balance) as" | ||
| + " age | fields age", | ||
| TEST_INDEX_BANK)); | ||
| verifyDataRows( | ||
| result, rows(new Object[] {null}), rows(40101.666666666664), rows(45570.666666666664)); | ||
|
andy-k-improving marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| @Test | ||
| public void testTrendlineNoAliasWma() throws IOException { | ||
| final JSONObject result = | ||
| executeQuery( | ||
| String.format( | ||
| "source=%s | where balance > 39000 | sort balance | trendline wma(2, balance) |" | ||
| + " fields balance_trendline", | ||
| TEST_INDEX_BANK)); | ||
| verifyDataRows( | ||
| result, rows(new Object[] {null}), rows(40101.666666666664), rows(45570.666666666664)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testTrendlineWithSortWma() throws IOException { | ||
| final JSONObject result = | ||
| executeQuery( | ||
| String.format( | ||
| "source=%s | where balance > 39000 | trendline sort balance wma(2, balance) |" | ||
| + " fields balance_trendline", | ||
| TEST_INDEX_BANK)); | ||
| verifyDataRows( | ||
| result, rows(new Object[] {null}), rows(40101.666666666664), rows(45570.666666666664)); | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add test with both wma and sma trendline default name
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated with test-cases: |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,6 +156,7 @@ trendlineClause | |
|
|
||
| trendlineType | ||
| : SMA | ||
| | WMA | ||
| ; | ||
|
|
||
| kmeansCommand | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.