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.
Base array functionality working with IT tests.
Signed-off-by: forestmvey <[email protected]>
- Loading branch information
1 parent
579d44a
commit 41d7bf5
Showing
8 changed files
with
118 additions
and
21 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
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
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
62 changes: 62 additions & 0 deletions
62
integ-test/src/test/java/org/opensearch/sql/sql/ArraysIT.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,62 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.sql; | ||
|
||
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ARRAYS; | ||
import static org.opensearch.sql.util.MatcherUtils.rows; | ||
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
import org.opensearch.sql.legacy.SQLIntegTestCase; | ||
|
||
public class ArraysIT extends SQLIntegTestCase { | ||
@Override | ||
public void init() throws IOException { | ||
loadIndex(Index.ARRAYS); | ||
} | ||
|
||
@Test | ||
public void object_array_index_1_test() { | ||
String query = "SELECT objectArray[0] FROM " + TEST_INDEX_ARRAYS; | ||
JSONObject result = executeJdbcRequest(query); | ||
|
||
verifyDataRows(result, | ||
rows(new JSONObject(ImmutableMap.of("innerObject", List.of(1, 2))))); | ||
} | ||
|
||
@Test | ||
public void object_array_index_1_inner_object_test() { | ||
String query = "SELECT objectArray[0].innerObject FROM " + TEST_INDEX_ARRAYS; | ||
JSONObject result = executeJdbcRequest(query); | ||
|
||
verifyDataRows(result, | ||
rows(new JSONArray(List.of(1, 2)))); | ||
} | ||
|
||
@Test | ||
public void object_array_index_1_inner_object_index_1_test() { | ||
String query = "SELECT objectArray[0].innerObject[0] FROM " + TEST_INDEX_ARRAYS; | ||
JSONObject result = executeJdbcRequest(query); | ||
|
||
verifyDataRows(result, | ||
rows(1)); | ||
} | ||
|
||
@Test | ||
public void multi_object_array_index_1_test() { | ||
String query = "SELECT multiObjectArray[0] FROM " + TEST_INDEX_ARRAYS; | ||
JSONObject result = executeJdbcRequest(query); | ||
|
||
verifyDataRows(result, | ||
rows(new JSONObject(ImmutableMap.of("id", 1, "name", "blah")))); | ||
} | ||
} |
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,2 @@ | ||
{"index":{"_id":"1"}} | ||
{"objectArray": [{"innerObject": [1, 2]}, {"innerObject": 3}], "multiObjectArray":[{"id": 1, "name": "blah"}, {"id": 2,"name": "hoo"}]} |
23 changes: 23 additions & 0 deletions
23
integ-test/src/test/resources/indexDefinitions/arrays_mapping.json
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,23 @@ | ||
{ | ||
"mappings": { | ||
"properties": { | ||
"objectArray": { | ||
"properties": { | ||
"innerObject": { | ||
"type": "keyword" | ||
} | ||
} | ||
}, | ||
"multiObjectArray": { | ||
"properties": { | ||
"id": { | ||
"type": "long" | ||
}, | ||
"name": { | ||
"type": "keyword" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |