Skip to content

Commit

Permalink
Addressed PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Guian Gumpac <[email protected]>
  • Loading branch information
GumpacG committed Jul 27, 2023
1 parent 937f82b commit 61aaa8f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
3 changes: 1 addition & 2 deletions docs/user/general/datatypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,10 @@ Geopoint Data Types
A geopoint has a latitude and a longitude property. Although OpenSearch `supports multiple formats <https://opensearch.org/docs/2.3/opensearch/supported-field-types/geo-point/>`_, the SQL plugin currently only supports the format :code:`{"lat": number, "lon": number}`. The geopoint object can be queried or lat and lon can be specified using dot notation. For example, ::

os> SELECT geo_point_object, geo_point_object.lat, geo_point_object.lon FROM geopoint;
fetched rows / total rows = 3/3
fetched rows / total rows = 2/2
+----------------------------------+------------------------+------------------------+
| geo_point_object | geo_point_object.lat | geo_point_object.lon |
|----------------------------------+------------------------+------------------------|
| {'lat': 40.71, 'lon': 74.0} | 40.71 | 74.0 |
| {'lat': -33.852, 'lon': 151.216} | -33.852 | 151.216 |
| null | null | null |
+----------------------------------+------------------------+------------------------+
1 change: 0 additions & 1 deletion doctest/test_data/geopoint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
{"geo_point_object": {"lat": 40.71, "lon": 74.00}}
{"geo_point_object": {"lat": -33.852, "lon": 151.216}}
{"geo_point_object": null}
36 changes: 28 additions & 8 deletions integ-test/src/test/java/org/opensearch/sql/sql/GeoPointIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,37 @@ public void test_geo_point() {

@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" +
String exceptionMessage =
" \"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" +
" }"
));
" }";

String geohashQuery = "SELECT geo_point_geohash FROM " + TEST_INDEX_GEOPOINT;
Exception exception = assertThrows(RuntimeException.class,
() -> executeJdbcRequest(geohashQuery));
assertTrue(exception.getMessage().contains(exceptionMessage));

String geopointString = "SELECT geo_point_string FROM " + TEST_INDEX_GEOPOINT;
exception = assertThrows(RuntimeException.class,
() -> executeJdbcRequest(geopointString));
assertTrue(exception.getMessage().contains(exceptionMessage));

String geopointArray = "SELECT geo_point_array FROM " + TEST_INDEX_GEOPOINT;
exception = assertThrows(RuntimeException.class,
() -> executeJdbcRequest(geopointArray));
assertTrue(exception.getMessage().contains(exceptionMessage));

String geopointStringPoint = "SELECT geo_point_string_point FROM " + TEST_INDEX_GEOPOINT;
exception = assertThrows(RuntimeException.class,
() -> executeJdbcRequest(geopointStringPoint));
assertTrue(exception.getMessage().contains(exceptionMessage));

String geopointGeoJSON = "SELECT geo_point_geojson FROM " + TEST_INDEX_GEOPOINT;
exception = assertThrows(RuntimeException.class,
() -> executeJdbcRequest(geopointGeoJSON));
assertTrue(exception.getMessage().contains(exceptionMessage));
}

@Test
Expand Down

0 comments on commit 61aaa8f

Please sign in to comment.