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 changes from POC PR Signed-off-by: Guian Gumpac <[email protected]> * Added geopoint parser for value factory Signed-off-by: Guian Gumpac <[email protected]> * Fixed old tests Signed-off-by: Guian Gumpac <[email protected]> * Fixed all old tests Signed-off-by: Guian Gumpac <[email protected]> * Removed irrelevant changes Signed-off-by: Guian Gumpac <[email protected]> * Removed irrelevant changes Signed-off-by: Guian Gumpac <[email protected]> * Added integration tests Signed-off-by: Guian Gumpac <[email protected]> * Fixed not throwing exception for geojson Signed-off-by: Guian Gumpac <[email protected]> * Made GeoPointValue an ExprTupleValue to enable access to lat and lon Signed-off-by: Guian Gumpac <[email protected]> * Fixed checkstyle Signed-off-by: Guian Gumpac <[email protected]> * Added unit tests and removed unnecessary code Signed-off-by: Guian Gumpac <[email protected]> * reverted irrelevant changes Signed-off-by: Guian Gumpac <[email protected]> * Added to docs Signed-off-by: Guian Gumpac <[email protected]> * Fixed doc typo Signed-off-by: Guian Gumpac <[email protected]> * Test doctests Signed-off-by: Guian Gumpac <[email protected]> * Test doctests Signed-off-by: Guian Gumpac <[email protected]> * Remove geopoint data from doctests Signed-off-by: Guian Gumpac <[email protected]> * Fixed doctest failure Signed-off-by: Guian Gumpac <[email protected]> * Fixed doctest failure Signed-off-by: Guian Gumpac <[email protected]> * Fix doctest clean up. Signed-off-by: Yury-Fridlyand <[email protected]> * Minimized doc example Signed-off-by: Guian Gumpac <[email protected]> * Fixed doctest Signed-off-by: Guian Gumpac <[email protected]> * Fixed doctest Signed-off-by: Guian Gumpac <[email protected]> * Fixed doctest Signed-off-by: Guian Gumpac <[email protected]> * Fixed doctest Signed-off-by: Guian Gumpac <[email protected]> * Fixed reordering of results Signed-off-by: Guian Gumpac <[email protected]> * Added more rows to doctests and removed IOException: Signed-off-by: Guian Gumpac <[email protected]> * Fixed doctest Signed-off-by: Guian Gumpac <[email protected]> * Fixed doctest Signed-off-by: Guian Gumpac <[email protected]> * Addressed PR comments Signed-off-by: Guian Gumpac <[email protected]> --------- Signed-off-by: Guian Gumpac <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]> Co-authored-by: Yury-Fridlyand <[email protected]>
- Loading branch information
1 parent
430d7a9
commit 937f82b
Showing
19 changed files
with
262 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{"geo_point_object": {"lat": 40.71, "lon": 74.00}} | ||
{"geo_point_object": {"lat": -33.852, "lon": 151.216}} | ||
{"geo_point_object": null} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"mappings": { | ||
"properties": { | ||
"geo_point_object": { | ||
"type": "geo_point" | ||
} | ||
} | ||
} | ||
} |
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
120 changes: 120 additions & 0 deletions
120
integ-test/src/test/java/org/opensearch/sql/sql/GeoPointIT.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,120 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.sql; | ||
|
||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
import org.opensearch.sql.legacy.SQLIntegTestCase; | ||
|
||
import java.util.Map; | ||
|
||
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_GEOPOINT; | ||
import static org.opensearch.sql.util.MatcherUtils.rows; | ||
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; | ||
|
||
public class GeoPointIT extends SQLIntegTestCase { | ||
@Override | ||
protected void init() throws Exception { | ||
loadIndex(Index.GEOPOINT); | ||
} | ||
|
||
@Test | ||
public void test_geo_point() { | ||
String query = "SELECT geo_point_object FROM " + TEST_INDEX_GEOPOINT; | ||
JSONObject result = executeJdbcRequest(query); | ||
verifyDataRows(result, | ||
rows(new JSONObject(Map.of( | ||
"lat", 40.71, | ||
"lon", 74))), | ||
rows(new JSONObject(Map.of( | ||
"lat", -33.85253637358241, | ||
"lon", 151.21652352950258))), | ||
rows(JSONObject.NULL) | ||
); | ||
} | ||
|
||
@Test | ||
public void test_geo_point_unsupported_format() { | ||
String query = "SELECT geo_point_geohash FROM " + TEST_INDEX_GEOPOINT; | ||
Exception exception = assertThrows(RuntimeException.class, | ||
() -> executeJdbcRequest(query)); | ||
|
||
assertTrue(exception.getMessage().contains( | ||
" \"error\": {\n" + | ||
" \"reason\": \"There was internal problem at backend\",\n" + | ||
" \"details\": \"geo point must be in format of {\\\"lat\\\": number, \\\"lon\\\": number}\",\n" + | ||
" \"type\": \"IllegalStateException\"\n" + | ||
" }" | ||
)); | ||
} | ||
|
||
@Test | ||
public void test_geo_point_in_objects() { | ||
String query = "SELECT object.geo_point_object FROM " + TEST_INDEX_GEOPOINT; | ||
JSONObject result = executeJdbcRequest(query); | ||
verifyDataRows(result, | ||
rows( | ||
(new JSONObject(Map.of( | ||
"lat", 40.71, | ||
"lon", 74)))), | ||
rows(new JSONObject(Map.of( | ||
"lat", -33.85253637358241, | ||
"lon", 151.21652352950258))), | ||
rows(JSONObject.NULL) | ||
); | ||
} | ||
|
||
@Test | ||
public void test_geo_point_lat_in_objects() { | ||
String query = "SELECT object.geo_point_object.lat FROM " + TEST_INDEX_GEOPOINT; | ||
JSONObject result = executeJdbcRequest(query); | ||
verifyDataRows(result, | ||
rows(40.71), | ||
rows( -33.85253637358241), | ||
rows(JSONObject.NULL) | ||
); | ||
} | ||
|
||
@Test | ||
public void test_geo_point_lat_and_lon() { | ||
String query = "SELECT geo_point_object.lat, geo_point_object.lon FROM " + TEST_INDEX_GEOPOINT; | ||
JSONObject result = executeJdbcRequest(query); | ||
verifyDataRows(result, | ||
rows(40.71, 74), | ||
rows(-33.85253637358241, 151.21652352950258), | ||
rows(JSONObject.NULL, JSONObject.NULL) | ||
); | ||
} | ||
|
||
@Test | ||
public void test_geo_point_object_with_lat_and_lon() { | ||
String query = "SELECT geo_point_object, geo_point_object.lat," + | ||
" geo_point_object.lon FROM " + TEST_INDEX_GEOPOINT; | ||
JSONObject result = executeJdbcRequest(query); | ||
verifyDataRows(result, | ||
rows(new JSONObject(Map.of( | ||
"lat", 40.71, | ||
"lon", 74)), | ||
40.71, 74), | ||
rows(new JSONObject(Map.of( | ||
"lat", -33.85253637358241, | ||
"lon", 151.21652352950258)), | ||
-33.85253637358241, 151.21652352950258), | ||
rows(JSONObject.NULL, JSONObject.NULL, JSONObject.NULL) | ||
); | ||
} | ||
|
||
@Test | ||
public void test_geo_point_lat_in_functions() { | ||
String query = "SELECT ABS(geo_point_object.lat) FROM " + TEST_INDEX_GEOPOINT; | ||
JSONObject result = executeJdbcRequest(query); | ||
verifyDataRows(result, | ||
rows(40.71), | ||
rows(33.85253637358241), | ||
rows(JSONObject.NULL) | ||
); | ||
} | ||
} |
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,6 @@ | ||
{"index":{"_id":"1"}} | ||
{"geo_point_object": {"lat": 40.71, "lon": 74.00}, "object": {"geo_point_object": {"lat": 40.71, "lon": 74.00}}, "geo_point_string": "40.71, 74.00", "geo_point_geohash": "txhxegj0uyp3", "geo_point_array": [74.00, 40.71], "geo_point_string_point": "POINT (74.00 40.71)", "geo_point_geojson": {"type": "Point", "coordinates": [74.00, 40.71]}} | ||
{"index":{"_id":"2"}} | ||
{"geo_point_object": {"lat": -33.85253637358241, "lon": 151.21652352950258}, "object": {"geo_point_object": {"lat": -33.85253637358241, "lon": 151.21652352950258}},"geo_point_string": "-33.85356510743158, 151.22222172610114", "geo_point_geohash": "txhxegj0uyp3", "geo_point_array": [74.00, 40.71], "geo_point_string_point": "POINT (74.00 40.71)", "geo_point_geojson": {"type": "Point", "coordinates": [74.00, 40.71]}} | ||
{"index":{"_id":"3"}} | ||
{"geo_point_object": null, "object": {"geo_point_object": null},"geo_point_string": null, "geo_point_geohash": null, "geo_point_array": null, "geo_point_string_point": null, "geo_point_geojson": null} |
32 changes: 32 additions & 0 deletions
32
integ-test/src/test/resources/indexDefinitions/geo_point_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,32 @@ | ||
{ | ||
"mappings": { | ||
"properties": { | ||
"geo_point_object": { | ||
"type": "geo_point" | ||
}, | ||
"object": { | ||
"type": "object", | ||
"properties": { | ||
"geo_point_object": { | ||
"type": "geo_point" | ||
} | ||
} | ||
}, | ||
"geo_point_string": { | ||
"type": "geo_point" | ||
}, | ||
"geo_point_geohash": { | ||
"type": "geo_point" | ||
}, | ||
"geo_point_array": { | ||
"type": "geo_point" | ||
}, | ||
"geo_point_string_point": { | ||
"type": "geo_point" | ||
}, | ||
"geo_point_geojson": { | ||
"type": "geo_point" | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.