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.
Added new exception for nested fields to force it to fallback to legacy
Signed-off-by: Guian Gumpac <[email protected]>
- Loading branch information
Showing
4 changed files
with
85 additions
and
1 deletion.
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
19 changes: 19 additions & 0 deletions
19
core/src/main/java/org/opensearch/sql/exception/UnsupportedV2NestedException.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,19 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
|
||
package org.opensearch.sql.exception; | ||
|
||
/** | ||
* Exception thrown to fall back to legacy when nested fields are queried. | ||
*/ | ||
public class UnsupportedV2NestedException extends QueryEngineException { | ||
public UnsupportedV2NestedException(String message) { | ||
super(message); | ||
} | ||
} | ||
|
||
|
||
|
56 changes: 56 additions & 0 deletions
56
integ-test/src/test/java/org/opensearch/sql/sql/NestedFallbackIT.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.sql; | ||
import org.json.JSONObject; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.opensearch.sql.legacy.SQLIntegTestCase; | ||
import java.io.IOException; | ||
|
||
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_NESTED_TYPE; | ||
import static org.opensearch.sql.util.MatcherUtils.schema; | ||
import static org.opensearch.sql.util.MatcherUtils.verifyColumn; | ||
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; | ||
import static org.opensearch.sql.util.MatcherUtils.rows; | ||
|
||
public class NestedFallbackIT extends SQLIntegTestCase{ | ||
@Override | ||
public void init() throws IOException { | ||
loadIndex(Index.NESTED); | ||
} | ||
|
||
@Test | ||
public void nested_function_and_without_nested_function_test() { | ||
String query = "SELECT nested(message.info), message.info FROM " + TEST_INDEX_NESTED_TYPE; | ||
JSONObject result = executeJdbcRequest(query); | ||
|
||
verifyColumn(result, schema("message.info", "keyword"), | ||
schema("message.info", "keyword")); | ||
verifyDataRows(result, rows("a", "a"), | ||
rows("b", "b"), | ||
rows("c", "c"), | ||
rows("c", "c"), | ||
rows("a", "a"), | ||
rows("zz", "zz")); | ||
} | ||
|
||
@Ignore("Legacy has a bug that returns nulls for array values. " + | ||
"This will be fixed in the new engine. https://github.com/opensearch-project/sql/issues/1218") | ||
@Test | ||
public void without_nested_function_test() { | ||
String query = "SELECT message.info FROM " + TEST_INDEX_NESTED_TYPE; | ||
JSONObject result = executeJdbcRequest(query); | ||
|
||
verifyColumn(result, schema("message.info", "keyword")); | ||
verifyDataRows(result, rows("a"), | ||
rows("b"), | ||
rows("c"), | ||
rows("c"), | ||
rows("a"), | ||
rows("zz")); | ||
} | ||
} |
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