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.
Fix result order of parse with other run time fields (opensearch-proj…
…ect#934) Signed-off-by: Joshua Li <[email protected]>
- Loading branch information
1 parent
05d53e7
commit 30a2d27
Showing
3 changed files
with
133 additions
and
17 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
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
69 changes: 69 additions & 0 deletions
69
integ-test/src/test/java/org/opensearch/sql/ppl/ParseCommandIT.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,69 @@ | ||
/* | ||
* 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.verifyOrder; | ||
|
||
import java.io.IOException; | ||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
|
||
public class ParseCommandIT extends PPLIntegTestCase { | ||
|
||
@Override | ||
public void init() throws IOException { | ||
loadIndex(Index.BANK); | ||
} | ||
|
||
@Test | ||
public void testParseCommand() throws IOException { | ||
JSONObject result = executeQuery( | ||
String.format("source=%s | parse email '.+@(?<host>.+)' | fields email, host", | ||
TEST_INDEX_BANK)); | ||
verifyOrder( | ||
result, | ||
rows("[email protected]", "pyrami.com"), | ||
rows("[email protected]", "netagy.com"), | ||
rows("[email protected]", "quility.com"), | ||
rows("[email protected]", "boink.com"), | ||
rows("[email protected]", "scentric.com"), | ||
rows("[email protected]", "filodyne.com"), | ||
rows("[email protected]", "quailcom.com")); | ||
} | ||
|
||
@Test | ||
public void testParseCommandReplaceOriginalField() throws IOException { | ||
JSONObject result = executeQuery( | ||
String.format("source=%s | parse email '.+@(?<email>.+)' | fields email", TEST_INDEX_BANK)); | ||
verifyOrder( | ||
result, | ||
rows("pyrami.com"), | ||
rows("netagy.com"), | ||
rows("quility.com"), | ||
rows("boink.com"), | ||
rows("scentric.com"), | ||
rows("filodyne.com"), | ||
rows("quailcom.com")); | ||
} | ||
|
||
@Test | ||
public void testParseCommandWithOtherRunTimeFields() throws IOException { | ||
JSONObject result = executeQuery(String.format("source=%s | parse email '.+@(?<host>.+)' | " | ||
+ "eval eval_result=1 | fields host, eval_result", TEST_INDEX_BANK)); | ||
verifyOrder( | ||
result, | ||
rows("pyrami.com", 1), | ||
rows("netagy.com", 1), | ||
rows("quility.com", 1), | ||
rows("boink.com", 1), | ||
rows("scentric.com", 1), | ||
rows("filodyne.com", 1), | ||
rows("quailcom.com", 1)); | ||
} | ||
} |