forked from opensearch-project/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Fallback to v1 engine for pagination #245
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
Merged
MaxKsyunz
merged 4 commits into
dev-pagination-v2_revC
from
dev-pagination-v2_revC_fallback
Mar 13, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
135 changes: 135 additions & 0 deletions
135
integ-test/src/test/java/org/opensearch/sql/sql/PaginationFallbackIT.java
This file contains hidden or 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,135 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package org.opensearch.sql.sql; | ||
|
|
||
| import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX; | ||
| import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ONLINE; | ||
| import static org.opensearch.sql.util.TestUtils.verifyIsV1Cursor; | ||
| import static org.opensearch.sql.util.TestUtils.verifyIsV2Cursor; | ||
|
|
||
| import java.io.IOException; | ||
| import org.json.JSONObject; | ||
| import org.junit.Test; | ||
| import org.opensearch.sql.legacy.SQLIntegTestCase; | ||
| import org.opensearch.sql.util.TestUtils; | ||
|
|
||
| public class PaginationFallbackIT extends SQLIntegTestCase { | ||
| @Override | ||
| public void init() throws IOException { | ||
| loadIndex(Index.PHRASE); | ||
| loadIndex(Index.ONLINE); | ||
| } | ||
|
|
||
| @Test | ||
| public void testWhereClause() throws IOException { | ||
| var response = executeQueryTemplate("SELECT * FROM %s WHERE 1 = 1", TEST_INDEX_ONLINE); | ||
| verifyIsV1Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSelectAll() throws IOException { | ||
| var response = executeQueryTemplate("SELECT * FROM %s", TEST_INDEX_ONLINE); | ||
| verifyIsV2Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSelectWithOpenSearchFuncInFilter() throws IOException { | ||
| var response = executeQueryTemplate( | ||
| "SELECT * FROM %s WHERE `11` = match_phrase('96')", TEST_INDEX_ONLINE); | ||
| verifyIsV1Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSelectWithHighlight() throws IOException { | ||
| var response = executeQueryTemplate( | ||
| "SELECT highlight(`11`) FROM %s WHERE match_query(`11`, '96')", TEST_INDEX_ONLINE); | ||
| // As of 2023-03-08, WHERE clause sends the query to legacy engine and legacy engine | ||
| // does not support highlight as an expression. | ||
| assertTrue(response.has("error")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSelectWithFullTextSearch() throws IOException { | ||
| var response = executeQueryTemplate( | ||
| "SELECT * FROM %s WHERE match_phrase(`11`, '96')", TEST_INDEX_ONLINE); | ||
| verifyIsV1Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSelectFromIndexWildcard() throws IOException { | ||
| var response = executeQueryTemplate("SELECT * FROM %s*", TEST_INDEX); | ||
| verifyIsV2Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSelectFromDataSource() throws IOException { | ||
| var response = executeQueryTemplate("SELECT * FROM @opensearch.%s", | ||
| TEST_INDEX_ONLINE); | ||
| verifyIsV2Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSelectColumnReference() throws IOException { | ||
| var response = executeQueryTemplate("SELECT `107` from %s", TEST_INDEX_ONLINE); | ||
| verifyIsV1Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSubquery() throws IOException { | ||
| var response = executeQueryTemplate("SELECT `107` from (SELECT * FROM %s)", | ||
| TEST_INDEX_ONLINE); | ||
| verifyIsV1Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSelectExpression() throws IOException { | ||
| var response = executeQueryTemplate("SELECT 1 + 1 - `107` from %s", | ||
| TEST_INDEX_ONLINE); | ||
| verifyIsV1Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGroupBy() throws IOException { | ||
| // GROUP BY is not paged by either engine. | ||
| var response = executeQueryTemplate("SELECT * FROM %s GROUP BY `107`", | ||
| TEST_INDEX_ONLINE); | ||
| TestUtils.verifyNoCursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGroupByHaving() throws IOException { | ||
| // GROUP BY is not paged by either engine. | ||
| var response = executeQueryTemplate("SELECT * FROM %s GROUP BY `107` HAVING `107` > 400", | ||
| TEST_INDEX_ONLINE); | ||
| TestUtils.verifyNoCursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLimit() throws IOException { | ||
| var response = executeQueryTemplate("SELECT * FROM %s LIMIT 8", TEST_INDEX_ONLINE); | ||
| verifyIsV1Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLimitOffset() throws IOException { | ||
| var response = executeQueryTemplate("SELECT * FROM %s LIMIT 8 OFFSET 4", | ||
| TEST_INDEX_ONLINE); | ||
| verifyIsV1Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOrderBy() throws IOException { | ||
| var response = executeQueryTemplate("SELECT * FROM %s ORDER By `107`", | ||
| TEST_INDEX_ONLINE); | ||
| verifyIsV1Cursor(response); | ||
| } | ||
|
|
||
| private JSONObject executeQueryTemplate(String queryTemplate, String index) throws IOException { | ||
| var query = String.format(queryTemplate, index); | ||
| return new JSONObject(executeFetchQuery(query, 4, "jdbc")); | ||
| } | ||
|
|
||
| } |
48 changes: 48 additions & 0 deletions
48
integ-test/src/test/java/org/opensearch/sql/sql/PaginationIT.java
This file contains hidden or 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,48 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package org.opensearch.sql.sql; | ||
|
|
||
| import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_CALCS; | ||
| import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ONLINE; | ||
|
|
||
| import java.io.IOException; | ||
| import org.json.JSONObject; | ||
| import org.junit.Test; | ||
| import org.opensearch.sql.legacy.SQLIntegTestCase; | ||
| import org.opensearch.sql.util.TestUtils; | ||
|
|
||
| public class PaginationIT extends SQLIntegTestCase { | ||
| @Override | ||
| public void init() throws IOException { | ||
| loadIndex(Index.CALCS); | ||
| loadIndex(Index.ONLINE); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSmallDataSet() throws IOException { | ||
| var query = "SELECT * from " + TEST_INDEX_CALCS; | ||
| var response = new JSONObject(executeFetchQuery(query, 4, "jdbc")); | ||
| assertTrue(response.has("cursor")); | ||
| assertEquals(4, response.getInt("size")); | ||
| TestUtils.verifyIsV2Cursor(response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLargeDataSetV1() throws IOException { | ||
| var v1query = "SELECT * from " + TEST_INDEX_ONLINE + " WHERE 1 = 1"; | ||
| var v1response = new JSONObject(executeFetchQuery(v1query, 4, "jdbc")); | ||
| assertEquals(4, v1response.getInt("size")); | ||
| TestUtils.verifyIsV1Cursor(v1response); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLargeDataSetV2() throws IOException { | ||
| var query = "SELECT * from " + TEST_INDEX_ONLINE; | ||
| var response = new JSONObject(executeFetchQuery(query, 4, "jdbc")); | ||
| assertEquals(4, response.getInt("size")); | ||
| TestUtils.verifyIsV2Cursor(response); | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.