forked from opensearch-project/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: James Duong <[email protected]>
- Loading branch information
Showing
2 changed files
with
77 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
integ-test/src/test/java/org/opensearch/sql/ppl/TrendlineCommandIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.ppl; | ||
|
||
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK; | ||
import static org.opensearch.sql.util.MatcherUtils.rows; | ||
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; | ||
|
||
import java.io.IOException; | ||
import org.json.JSONObject; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class TrendlineCommandIT extends PPLIntegTestCase { | ||
|
||
@Override | ||
public void init() throws IOException { | ||
loadIndex(Index.BANK); | ||
} | ||
|
||
@Test | ||
public void testTrendline() throws IOException { | ||
final JSONObject result = | ||
executeQuery( | ||
String.format( | ||
"source=%s | where balance > 39000 | sort balance | trendline sma(2, balance) as" | ||
+ " balance_trend | fields balance_trend", | ||
TEST_INDEX_BANK)); | ||
verifyDataRows(result, rows(new Object[] {null}), rows(44313.0), rows(39882.5)); | ||
} | ||
|
||
@Test | ||
public void testTrendlineMultipleFields() throws IOException { | ||
final JSONObject result = | ||
executeQuery( | ||
String.format( | ||
"source=%s | where balance > 39000 | sort balance | trendline sma(2, balance) as" | ||
+ " balance_trend sma(2, account_number) as account_number_trend | fields" | ||
+ " balance_trend, account_number_trend", | ||
TEST_INDEX_BANK)); | ||
verifyDataRows(result, rows(null, null), rows(44313.0, 28.5), rows(39882.5, 13.0)); | ||
} | ||
|
||
@Test | ||
public void testTrendlineOverwritesExistingField() throws IOException { | ||
final JSONObject result = | ||
executeQuery( | ||
String.format( | ||
"source=%s | where balance > 39000 | sort balance | trendline sma(2, balance) as" | ||
+ " age | fields age", | ||
TEST_INDEX_BANK)); | ||
verifyDataRows(result, rows(new Object[] {null}), rows(44313.0), rows(39882.5)); | ||
} | ||
} |