Skip to content
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

SQL: Add initial geo support #42031

Merged
merged 89 commits into from
May 14, 2019
Merged
Changes from 1 commit
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
1157c11
Sql add support for geo shape type (#4204)
imotov May 8, 2018
f890bc6
Merge remote-tracking branch 'elastic/master' into geosql
imotov Jun 8, 2018
61e92f1
Fix qa-sql h2gis dependency
imotov Jun 8, 2018
b512e55
Merge remote-tracking branch 'elastic/master' into geosql
imotov Jun 11, 2018
62a2937
SQL: Add basic support for geo point (#31257)
imotov Jun 12, 2018
80e91cc
Merge remote-tracking branch 'elastic/master' into geosql
imotov Jul 16, 2018
cc5768e
Merge remote-tracking branch 'elastic/master' into geosql
imotov Aug 7, 2018
f73797a
Merge remote-tracking branch 'elastic/master' into geosql
imotov Sep 24, 2018
819045b
Tests: Fix client call in GeoDataLoader after merge
imotov Sep 24, 2018
2164893
Tests: add a workaround for testing timestamps in H2 v1.4.196
imotov Sep 25, 2018
642f1cf
Merge remote-tracking branch 'elastic/master' into geosql
imotov Sep 26, 2018
a561593
Tests: Fix merge in JdbcAssert
imotov Sep 26, 2018
6d6a0a4
Merge remote-tracking branch 'elastic/master' into geosql
imotov Oct 1, 2018
0301e6b
Merge remote-tracking branch 'elastic/master' into geosql
imotov Oct 18, 2018
0280428
SQL: Add basic support for ST_AsWKT geo function (#34205)
imotov Oct 23, 2018
09897ba
Merge remote-tracking branch 'elastic/master' into geosql
imotov Oct 23, 2018
49f859c
Merge remote-tracking branch 'elastic/master' into geosql
imotov Nov 1, 2018
99d9e2f
SQL: Fix geosql show function tests after master merge
imotov Nov 2, 2018
6f0b2fb
SQL: Fix geo tests after move of qa directory
imotov Nov 2, 2018
8e79977
Merge remote-tracking branch 'elastic/master' into geosql
imotov Nov 8, 2018
e5fd7f4
Merge remote-tracking branch 'elastic/master' into geosql
imotov Nov 8, 2018
78dfa50
SQL: Fix logger in LocalH2-based tests
imotov Nov 8, 2018
76be286
Merge remote-tracking branch 'elastic/master' into geosql
imotov Nov 9, 2018
bfedbbb
Merge remote-tracking branch 'elastic/master' into geosql
imotov Nov 14, 2018
1ac1177
Merge remote-tracking branch 'elastic/master' into geosql
imotov Nov 14, 2018
08da5bb
SQL: Add ST_WktToSQL function (#35416)
imotov Nov 15, 2018
52ddf5a
Merge remote-tracking branch 'elastic/master' into geosql
imotov Nov 16, 2018
de31429
Merge remote-tracking branch 'elastic/master' into geosql
imotov Nov 20, 2018
e35c9b7
Merge remote-tracking branch 'elastic/master' into geosql
imotov Nov 21, 2018
69a27cf
Merge remote-tracking branch 'elastic/master' into geosql
imotov Nov 21, 2018
83023f3
Merge remote-tracking branch 'elastic/master' into geosql
imotov Dec 4, 2018
27aba15
Merge remote-tracking branch 'elastic/master' into geosql
imotov Dec 7, 2018
a039f10
Merge remote-tracking branch 'elastic/master' into geosql
imotov Jan 14, 2019
a5ad3f9
SQL: Fix compilation error in St-functions after master merge
imotov Jan 14, 2019
4b9da09
Merge remote-tracking branch 'elastic/master' into geosql
imotov Jan 15, 2019
d12a7a7
SQL: remove type from geo mappings
imotov Jan 15, 2019
dfaeaa9
Merge remote-tracking branch 'elastic/master' into geosql
imotov Feb 11, 2019
c715326
Merge remote-tracking branch 'elastic/master' into geosql
imotov Feb 19, 2019
d5d52f2
Merge remote-tracking branch 'elastic/master' into geosql
imotov Feb 20, 2019
3a0411f
Merge remote-tracking branch 'elastic/master' into geosql
imotov Feb 26, 2019
44542b0
SQL: Switch JDBC driver to libs/geo objects for geo_shapes (#39204)
imotov Feb 27, 2019
787eef6
Merge remote-tracking branch 'elastic/master' into geosql
imotov Feb 27, 2019
078dcf0
SQL: Switch JDBC driver to libs/geo objects for geo_points (#39484)
imotov Mar 1, 2019
d497ba2
Merge remote-tracking branch 'elastic/master' into geosql
imotov Mar 1, 2019
8d1d944
Merge remote-tracking branch 'elastic/master' into geosql
imotov Mar 4, 2019
0ff9e3c
Merge remote-tracking branch 'elastic/master' into geosql
imotov Mar 7, 2019
943f4eb
SQL: suppress Geosql tests if locale doesn't use - for negative numbe…
imotov Mar 8, 2019
584b74c
Merge remote-tracking branch 'elastic/master' into geosql
imotov Mar 12, 2019
2ba546e
Merge remote-tracking branch 'elastic/master' into geosql
imotov Mar 20, 2019
223f756
SQL: Make TIME_ZONE constant public for geosql
imotov Mar 20, 2019
82ad403
SQL: Add ST_Distance function to geosql (#39973)
imotov Mar 22, 2019
415d651
Merge remote-tracking branch 'elastic/master' into geosql
imotov Mar 22, 2019
ece7d92
Merge remote-tracking branch 'elastic/master' into geosql
imotov Mar 25, 2019
1ad9d0b
SQL: Upgrade H2GIS library to 1.5.0 (#40461)
imotov Mar 27, 2019
f44f35d
Merge remote-tracking branch 'elastic/master' into geosql
imotov Mar 27, 2019
886830f
Merge remote-tracking branch 'elastic/master' into geosql
imotov Mar 28, 2019
b4231c9
Merge remote-tracking branch 'elastic/master' into geosql
imotov Apr 1, 2019
ed0c0e6
SQL: Convert ST_Distance into query when possible (#40595)
imotov Apr 2, 2019
1ac266a
Merge remote-tracking branch 'elastic/master' into geosql
imotov Apr 2, 2019
513eba1
Merge remote-tracking branch 'elastic/master' into geosql
imotov Apr 9, 2019
ee64cc9
Merge remote-tracking branch 'elastic/master' into geosql
imotov Apr 9, 2019
d7647c8
SQL: Improve null handling in Geo Functions (#40708)
imotov Apr 10, 2019
c6d611b
Merge remote-tracking branch 'elastic/master' into geosql
imotov Apr 10, 2019
07ad376
Merge remote-tracking branch 'elastic/master' into geosql
imotov Apr 14, 2019
dd07273
SQL: Add ST_X, ST_Y and ST_GEOMETRY_TYPE functions (#41104)
imotov Apr 22, 2019
d7e4c46
Merge remote-tracking branch 'elastic/master' into geosql
imotov Apr 22, 2019
1543cf7
Merge remote-tracking branch 'elastic/master' into geosql
imotov Apr 23, 2019
d193922
Merge remote-tracking branch 'elastic/master' into geosql
imotov Apr 28, 2019
01b6c79
Merge remote-tracking branch 'elastic/master' into geosql
imotov Apr 30, 2019
00e9c79
Merge remote-tracking branch 'elastic/master' into geosql
imotov May 2, 2019
b2f0435
SQL: Switch server side for geosql from ShapeBuilder to libs/geo (#41…
imotov May 2, 2019
7b8ab09
Merge remote-tracking branch 'elastic/master' into geosql
imotov May 3, 2019
d5a43c3
SQL: Add ST_Z function (#41772)
imotov May 6, 2019
7e1999a
Merge remote-tracking branch 'elastic/master' into geosql
imotov May 6, 2019
a3c138a
Update TLS ciphers and protocols for JDK 11 (#41808)
jaymode May 7, 2019
502b395
Correct spelling of MockLogAppender.PatternSeenEventExpectation (#41893)
romseygeek May 7, 2019
a99fc23
Handle serialization exceptions during publication (#41781)
DaveCTurner May 7, 2019
8bff716
[DOCS] Fix callouts for dataframe APIs (#41904)
lcawl May 7, 2019
1559a8e
SQL: Remove CircuitBreaker from parser (#41835)
matriv May 7, 2019
907b917
SQL: Add non-zero display size for geo types (#41869)
imotov May 7, 2019
62f9606
Merge remote-tracking branch 'elastic/master' into geosql
imotov May 7, 2019
e9e7f33
Merge remote-tracking branch 'elastic/master' into geosql
imotov May 8, 2019
1f2b580
Merge remote-tracking branch 'elastic/master' into geosql
imotov May 8, 2019
da72ce1
SQL: Improve error messages for geo_shape (#41923)
imotov May 9, 2019
8398455
Merge remote-tracking branch 'elastic/master' into geosql
imotov May 9, 2019
87f74f8
Remove unnecessary binary files in x-pack/plugin/ml/cpp-snapshot/.cache
imotov May 9, 2019
b51dfef
Merge remote-tracking branch 'elastic/master' into geosql
imotov May 9, 2019
a17603c
Merge remote-tracking branch 'elastic/master' into geosql
imotov May 13, 2019
881a357
Fix tests to work with #41558
imotov May 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
SQL: Add basic support for geo point (#31257)
Adds basic support for geo point type. For now, the geopoint is
represented as a string and returned in the same format it was stored
in the source.

Relates to #29872
  • Loading branch information
imotov authored Jun 12, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 62a2937d74789fb6119e5722f39a08c17b0da840
Original file line number Diff line number Diff line change
@@ -42,14 +42,16 @@ public enum DataType {
// see https://github.com/elastic/elasticsearch/issues/30386#issuecomment-386807288
DATE( JDBCType.TIMESTAMP, Timestamp.class, Long.BYTES, 24, 24),
// TODO: This should map to some Geography class instead of String
GEO_SHAPE( JDBCType.OTHER, String.class, Integer.MAX_VALUE, Integer.MAX_VALUE, 0, false, false, false);
GEO_SHAPE( JDBCType.OTHER, String.class, Integer.MAX_VALUE, Integer.MAX_VALUE, 0, false, false, false),
GEO_POINT( JDBCType.OTHER, String.class, Double.BYTES*2, Integer.MAX_VALUE, 0, false, false, false);
// @formatter:on

private static final Map<JDBCType, DataType> jdbcToEs;

static {
jdbcToEs = Arrays.stream(DataType.values())
.filter(dataType -> dataType != TEXT && dataType != NESTED && dataType != SCALED_FLOAT && dataType != GEO_SHAPE)
.filter(dataType -> dataType != TEXT && dataType != NESTED && dataType != SCALED_FLOAT && dataType != GEO_SHAPE &&
dataType != GEO_POINT)
.collect(Collectors.toMap(dataType -> dataType.jdbcType, dataType -> dataType));
}

Original file line number Diff line number Diff line change
@@ -58,11 +58,11 @@ public void testSysTypes() throws Exception {
Command cmd = sql("SYS TYPES").v1();

List<String> names = asList("BYTE", "LONG", "BINARY", "NULL", "INTEGER", "SHORT", "HALF_FLOAT", "SCALED_FLOAT", "FLOAT", "DOUBLE",
"KEYWORD", "TEXT", "BOOLEAN", "DATE", "UNSUPPORTED", "GEO_SHAPE", "OBJECT", "NESTED");
"KEYWORD", "TEXT", "BOOLEAN", "DATE", "UNSUPPORTED", "GEO_SHAPE", "GEO_POINT", "OBJECT", "NESTED");

cmd.execute(null, ActionListener.wrap(r -> {
assertEquals(19, r.columnCount());
assertEquals(18, r.size());
assertEquals(names.size(), r.size());
assertFalse(r.schema().types().contains(DataType.NULL));
// test numeric as signed
assertFalse(r.column(9, Boolean.class));
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@

import static java.util.Collections.emptyMap;
import static org.elasticsearch.xpack.sql.type.DataType.DATE;
import static org.elasticsearch.xpack.sql.type.DataType.GEO_POINT;
import static org.elasticsearch.xpack.sql.type.DataType.GEO_SHAPE;
import static org.elasticsearch.xpack.sql.type.DataType.INTEGER;
import static org.elasticsearch.xpack.sql.type.DataType.KEYWORD;
@@ -39,13 +40,12 @@ public void testEmptyMap() {

public void testBasicMapping() {
Map<String, EsField> mapping = loadMapping("mapping-basic.json");
assertThat(mapping.size(), is(7));
assertThat(mapping.size(), is(6));
assertThat(mapping.get("emp_no").getDataType(), is(INTEGER));
assertThat(mapping.get("first_name"), instanceOf(TextEsField.class));
assertThat(mapping.get("last_name").getDataType(), is(TEXT));
assertThat(mapping.get("gender").getDataType(), is(KEYWORD));
assertThat(mapping.get("salary").getDataType(), is(INTEGER));
assertThat(mapping.get("site").getDataType(), is(GEO_SHAPE));
}

public void testDefaultStringMapping() {
@@ -181,8 +181,11 @@ public void testNestedDoc() {

public void testGeoField() {
Map<String, EsField> mapping = loadMapping("mapping-geo.json");
EsField dt = mapping.get("location");
assertThat(dt.getDataType().esType, is("unsupported"));
assertThat(mapping.size(), is(2));
EsField gp = mapping.get("location");
assertThat(gp.getDataType().esType, is("geo_point"));
EsField gs = mapping.get("site");
assertThat(gs.getDataType().esType, is("geo_shape"));
}

public void testUnsupportedTypes() {
@@ -202,4 +205,4 @@ public static Map<String, EsField> loadMapping(String name, boolean ordered) {
assertNotNull("Could not find mapping resource:" + name, stream);
return Types.fromEs(XContentHelper.convertToMap(JsonXContent.jsonXContent, stream, ordered));
}
}
}
3 changes: 0 additions & 3 deletions x-pack/plugin/sql/src/test/resources/mapping-basic.json
Original file line number Diff line number Diff line change
@@ -17,9 +17,6 @@
},
"salary" : {
"type" : "integer"
},
"site": {
"type": "geo_shape"
}
}
}
3 changes: 3 additions & 0 deletions x-pack/plugin/sql/src/test/resources/mapping-geo.json
Original file line number Diff line number Diff line change
@@ -2,6 +2,9 @@
"properties" : {
"location" : {
"type" : "geo_point"
},
"site": {
"type" : "geo_shape"
}
}
}
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
package org.elasticsearch.xpack.qa.sql.geo;

import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.client.Request;
import org.elasticsearch.xpack.qa.sql.jdbc.CsvTestUtils.CsvTestCase;
import org.elasticsearch.xpack.qa.sql.jdbc.SpecBaseIntegrationTestCase;
import org.elasticsearch.xpack.sql.jdbc.jdbc.JdbcConfiguration;
@@ -34,6 +35,7 @@ public static List<Object[]> readScriptSpec() throws Exception {
Parser parser = specParser();
List<Object[]> tests = new ArrayList<>();
tests.addAll(readScriptSpec("/ogc/ogc.csv-spec", parser));
tests.addAll(readScriptSpec("/geo/geosql.csv-spec", parser));
return tests;
}

@@ -45,8 +47,11 @@ public GeoCsvSpecTestCase(String fileName, String groupName, String testName, In

@Before
public void setupTestGeoDataIfNeeded() throws Exception {
if (client().performRequest("HEAD", "/ogc").getStatusLine().getStatusCode() == 404) {
GeoDataLoader.loadDatasetIntoEs(client());
if (client().performRequest(new Request("HEAD", "/ogc")).getStatusLine().getStatusCode() == 404) {
GeoDataLoader.loadOGCDatasetIntoEs(client(), "ogc");
}
if (client().performRequest(new Request("HEAD", "/geo")).getStatusLine().getStatusCode() == 404) {
GeoDataLoader.loadGeoDatasetIntoEs(client(), "geo");
}
}

Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.common.Strings;
@@ -37,26 +38,28 @@ public class GeoDataLoader {

public static void main(String[] args) throws Exception {
try (RestClient client = RestClient.builder(new HttpHost("localhost", 9200)).build()) {
loadDatasetIntoEs(client);
loadOGCDatasetIntoEs(client, "ogc");
loadGeoDatasetIntoEs(client, "geo");
Loggers.getLogger(GeoDataLoader.class).info("Geo data loaded");
}
}

protected static void loadDatasetIntoEs(RestClient client) throws Exception {
loadDatasetIntoEs(client, "ogc");
makeFilteredAlias(client, "lakes", "ogc", "\"term\" : { \"ogc_type\" : \"lakes\" }");
makeFilteredAlias(client, "road_segments", "ogc", "\"term\" : { \"ogc_type\" : \"road_segments\" }");
makeFilteredAlias(client, "divided_routes", "ogc", "\"term\" : { \"ogc_type\" : \"divided_routes\" }");
makeFilteredAlias(client, "forests", "ogc", "\"term\" : { \"ogc_type\" : \"forests\" }");
makeFilteredAlias(client, "bridges", "ogc", "\"term\" : { \"ogc_type\" : \"bridges\" }");
makeFilteredAlias(client, "streams", "ogc", "\"term\" : { \"ogc_type\" : \"streams\" }");
makeFilteredAlias(client, "buildings", "ogc", "\"term\" : { \"ogc_type\" : \"buildings\" }");
makeFilteredAlias(client, "ponds", "ogc", "\"term\" : { \"ogc_type\" : \"ponds\" }");
makeFilteredAlias(client, "named_places", "ogc", "\"term\" : { \"ogc_type\" : \"named_places\" }");
makeFilteredAlias(client, "map_neatlines", "ogc", "\"term\" : { \"ogc_type\" : \"map_neatlines\" }");
protected static void loadOGCDatasetIntoEs(RestClient client, String index) throws Exception {
createIndex(client, index, createOGCIndexRequest());
loadData(client, index, readResource("/ogc/ogc.json"));
makeFilteredAlias(client, "lakes", index, "\"term\" : { \"ogc_type\" : \"lakes\" }");
makeFilteredAlias(client, "road_segments", index, "\"term\" : { \"ogc_type\" : \"road_segments\" }");
makeFilteredAlias(client, "divided_routes", index, "\"term\" : { \"ogc_type\" : \"divided_routes\" }");
makeFilteredAlias(client, "forests", index, "\"term\" : { \"ogc_type\" : \"forests\" }");
makeFilteredAlias(client, "bridges", index, "\"term\" : { \"ogc_type\" : \"bridges\" }");
makeFilteredAlias(client, "streams", index, "\"term\" : { \"ogc_type\" : \"streams\" }");
makeFilteredAlias(client, "buildings", index, "\"term\" : { \"ogc_type\" : \"buildings\" }");
makeFilteredAlias(client, "ponds", index, "\"term\" : { \"ogc_type\" : \"ponds\" }");
makeFilteredAlias(client, "named_places", index, "\"term\" : { \"ogc_type\" : \"named_places\" }");
makeFilteredAlias(client, "map_neatlines", index, "\"term\" : { \"ogc_type\" : \"map_neatlines\" }");
}

protected static void loadDatasetIntoEs(RestClient client, String index) throws Exception {
private static String createOGCIndexRequest() throws Exception {
XContentBuilder createIndex = JsonXContent.contentBuilder().startObject();
createIndex.startObject("settings");
{
@@ -101,12 +104,21 @@ protected static void loadDatasetIntoEs(RestClient client, String index) throws
createIndex.endObject();
}
createIndex.endObject().endObject();
return Strings.toString(createIndex);
}

client.performRequest("PUT", "/" + index, emptyMap(), new StringEntity(Strings.toString(createIndex),
ContentType.APPLICATION_JSON));
private static void createIndex(RestClient client, String index, String settingsMappings) throws IOException {
Request createIndexRequest = new Request("PUT", "/" + index);
createIndexRequest.setEntity(new StringEntity(settingsMappings, ContentType.APPLICATION_JSON));
client.performRequest(createIndexRequest);
}

String bulk = readResource("/ogc/ogc.json");
static void loadGeoDatasetIntoEs(RestClient client, String index) throws Exception {
createIndex(client, index, readResource("/geo/geosql.json"));
loadData(client, index, readResource("/geo/geosql-bulk.json"));
}

private static void loadData(RestClient client, String index, String bulk) throws IOException {
Response response = client.performRequest("POST", "/" + index + "/doc/_bulk", singletonMap("refresh", "true"),
new StringEntity(bulk, ContentType.APPLICATION_JSON));

Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
package org.elasticsearch.xpack.qa.sql.geo;

import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.client.Request;
import org.elasticsearch.xpack.qa.sql.jdbc.LocalH2;
import org.elasticsearch.xpack.qa.sql.jdbc.SpecBaseIntegrationTestCase;
import org.elasticsearch.xpack.sql.jdbc.jdbc.JdbcConfiguration;
@@ -47,8 +48,8 @@ public static List<Object[]> readScriptSpec() throws Exception {
public void setupTestGeoDataIfNeeded() throws Exception {
assumeTrue("Cannot support locales that don't use Hindu-Arabic numerals due to H2",
"42".equals(NumberFormat.getInstance(Locale.getDefault()).format(42)));
if (client().performRequest("HEAD", "/ogc").getStatusLine().getStatusCode() == 404) {
GeoDataLoader.loadDatasetIntoEs(client());
if (client().performRequest(new Request("HEAD", "/ogc")).getStatusLine().getStatusCode() == 404) {
GeoDataLoader.loadOGCDatasetIntoEs(client(), "ogc");
}
}

33 changes: 33 additions & 0 deletions x-pack/qa/sql/src/main/resources/geo/geosql-bulk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{"index":{"_id": "1"}}
{"region": "Americas", "city": "Mountain View", "location": "37.386483,-122.083843"}
{"index":{"_id": "2"}}
{"region": "Americas", "city": "Chicago", "location": "41.888783,-87.637874"}
{"index":{"_id": "3"}}
{"region": "Americas", "city": "New York", "location": "40.745171,-73.990027"}
{"index":{"_id": "4"}}
{"region": "Americas", "city": "San Francisco", "location": "37.789541,-122.394228"}
{"index":{"_id": "5"}}
{"region": "Americas", "city": "Phoenix", "location": "33.376242,-111.973505"}
{"index":{"_id": "6"}}
{"region": "Europe", "city": "Amsterdam", "location": "52.347557,4.850312"}
{"index":{"_id": "7"}}
{"region": "Europe", "city": "Berlin", "location": "52.486701,13.390889"}
{"index":{"_id": "8"}}
{"region": "Europe", "city": "Munich", "location": "48.146321,11.537505"}
{"index":{"_id": "9"}}
{"region": "Europe", "city": "London", "location": "51.510871,-0.121672"}
{"index":{"_id": "10"}}
{"region": "Europe", "city": "Paris", "location": "48.845538,2.351773"}
{"index":{"_id": "11"}}
{"region": "Asia", "city": "Singapore", "location": "1.295868,103.855535"}
{"index":{"_id": "12"}}
{"region": "Asia", "city": "Hong Kong", "location": "22.281397,114.183925"}
{"index":{"_id": "13"}}
{"region": "Asia", "city": "Seoul", "location": "37.509132,127.060851"}
{"index":{"_id": "14"}}
{"region": "Asia", "city": "Tokyo", "location": "35.669616,139.76402225"}
{"index":{"_id": "15"}}
{"region": "Asia", "city": "Sydney", "location": "-33.863385,151.208629"}



45 changes: 45 additions & 0 deletions x-pack/qa/sql/src/main/resources/geo/geosql.csv-spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Commands on geo test data
//

showTables
SHOW TABLES 'geo';

name:s | type:s
geo |BASE TABLE
;

// DESCRIBE

describe
DESCRIBE "geo";

column:s | type:s
city | VARCHAR
location | OTHER
region | VARCHAR
;

// SELECT ALL
// TODO: For now we just get geopoint formatted as is and we also need to convert it to STRING to work with CSV

selectAllPoints
SELECT city, CAST(location AS STRING) location, region FROM "geo" ORDER BY "city";

city:s | location:s | region:s
Amsterdam |52.347557,4.850312 |Europe
Berlin |52.486701,13.390889 |Europe
Chicago |41.888783,-87.637874 |Americas
Hong Kong |22.281397,114.183925 |Asia
London |51.510871,-0.121672 |Europe
Mountain View |37.386483,-122.083843 |Americas
Munich |48.146321,11.537505 |Europe
New York |40.745171,-73.990027 |Americas
Paris |48.845538,2.351773 |Europe
Phoenix |33.376242,-111.973505 |Americas
San Francisco |37.789541,-122.394228 |Americas
Seoul |37.509132,127.060851 |Asia
Singapore |1.295868,103.855535 |Asia
Sydney |-33.863385,151.208629 |Asia
Tokyo |35.669616,139.76402225|Asia
;
20 changes: 20 additions & 0 deletions x-pack/qa/sql/src/main/resources/geo/geosql.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"settings": {
"number_of_shards": 1
},
"mappings": {
"doc": {
"properties": {
"region": {
"type": "keyword"
},
"city": {
"type": "keyword"
},
"location": {
"type": "geo_point"
}
}
}
}
}