SQL: Add support for shape type (#46464)
Enables support for Cartesian geometries shape type. We still need to decide how to handle the distance function since it is currently using the haversine distance formula and returns results in meters, which doesn't make any sense for Cartesian geometries. Closes #46412 Relates to #43644
This commit is contained in:
parent
0c575dc1e8
commit
ae202fda21
|
@ -5,14 +5,15 @@
|
|||
|
||||
beta[]
|
||||
|
||||
The geo functions work with geometries stored in `geo_point` and `geo_shape` fields, or returned by other geo functions.
|
||||
The geo functions work with geometries stored in `geo_point`, `geo_shape` and `shape` fields, or returned by other geo functions.
|
||||
|
||||
==== Limitations
|
||||
|
||||
Both <<geo-point, `geo_point`>> and <<geo-shape, `geo_shape`>> types are represented in SQL as geometry and can be used
|
||||
interchangeably with the following exceptions:
|
||||
<<geo-point, `geo_point`>>, <<geo-shape, `geo_shape`>> and <<shape, `shape`>> and types are represented in SQL as
|
||||
geometry and can be used interchangeably with the following exceptions:
|
||||
|
||||
* `geo_shape` fields don't have doc values, therefore these fields cannot be used for filtering, grouping or sorting.
|
||||
* `geo_shape` and `shape` fields don't have doc values, therefore these fields cannot be used for filtering, grouping
|
||||
or sorting.
|
||||
|
||||
* `geo_points` fields are indexed and have doc values by default, however only latitude and longitude are stored and
|
||||
indexed with some loss of precision from the original values (4.190951585769653E-8 for the latitude and
|
||||
|
|
|
@ -83,6 +83,7 @@ s|SQL precision
|
|||
| interval_minute_to_second | 23
|
||||
| geo_point | 52
|
||||
| geo_shape | 2,147,483,647
|
||||
| shape | 2,147,483,647
|
||||
|
||||
|===
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.sql.SQLType;
|
|||
import java.sql.Types;
|
||||
|
||||
public enum EsType implements SQLType {
|
||||
|
||||
|
||||
NULL( Types.NULL),
|
||||
UNSUPPORTED( Types.OTHER),
|
||||
BOOLEAN( Types.BOOLEAN),
|
||||
|
@ -46,7 +46,8 @@ public enum EsType implements SQLType {
|
|||
INTERVAL_HOUR_TO_SECOND( ExtraTypes.INTERVAL_HOUR_SECOND),
|
||||
INTERVAL_MINUTE_TO_SECOND(ExtraTypes.INTERVAL_MINUTE_SECOND),
|
||||
GEO_POINT( ExtraTypes.GEOMETRY),
|
||||
GEO_SHAPE( ExtraTypes.GEOMETRY);
|
||||
GEO_SHAPE( ExtraTypes.GEOMETRY),
|
||||
SHAPE( ExtraTypes.GEOMETRY);
|
||||
|
||||
private final Integer type;
|
||||
|
||||
|
|
|
@ -248,6 +248,7 @@ final class TypeConverter {
|
|||
return Duration.parse(v.toString());
|
||||
case GEO_POINT:
|
||||
case GEO_SHAPE:
|
||||
case SHAPE:
|
||||
try {
|
||||
return WKT.fromWKT(v.toString());
|
||||
} catch (IOException | ParseException ex) {
|
||||
|
|
|
@ -94,6 +94,7 @@ final class TypeUtils {
|
|||
types.put(EsType.INTERVAL_MINUTE_TO_SECOND, Duration.class);
|
||||
types.put(EsType.GEO_POINT, String.class);
|
||||
types.put(EsType.GEO_SHAPE, String.class);
|
||||
types.put(EsType.SHAPE, String.class);
|
||||
|
||||
TYPE_TO_CLASS = unmodifiableMap(types);
|
||||
|
||||
|
|
|
@ -73,25 +73,25 @@ public class GeoDataLoader {
|
|||
createString("name", createIndex);
|
||||
|
||||
// Type specific
|
||||
createIndex.startObject("shore").field("type", "geo_shape").endObject(); // lakes
|
||||
createIndex.startObject("shore").field("type", "shape").endObject(); // lakes
|
||||
|
||||
createString("aliases", createIndex); // road_segments
|
||||
createIndex.startObject("num_lanes").field("type", "integer").endObject(); // road_segments, divided_routes
|
||||
createIndex.startObject("centerline").field("type", "geo_shape").endObject(); // road_segments, streams
|
||||
createIndex.startObject("centerline").field("type", "shape").endObject(); // road_segments, streams
|
||||
|
||||
createIndex.startObject("centerlines").field("type", "geo_shape").endObject(); // divided_routes
|
||||
createIndex.startObject("centerlines").field("type", "shape").endObject(); // divided_routes
|
||||
|
||||
createIndex.startObject("boundary").field("type", "geo_shape").endObject(); // forests, named_places
|
||||
createIndex.startObject("boundary").field("type", "shape").endObject(); // forests, named_places
|
||||
|
||||
createIndex.startObject("position").field("type", "geo_shape").endObject(); // bridges, buildings
|
||||
createIndex.startObject("position").field("type", "shape").endObject(); // bridges, buildings
|
||||
|
||||
createString("address", createIndex); // buildings
|
||||
createIndex.startObject("footprint").field("type", "geo_shape").endObject(); // buildings
|
||||
createIndex.startObject("footprint").field("type", "shape").endObject(); // buildings
|
||||
|
||||
createIndex.startObject("type").field("type", "keyword").endObject(); // ponds
|
||||
createIndex.startObject("shores").field("type", "geo_shape").endObject(); // ponds
|
||||
createIndex.startObject("shores").field("type", "shape").endObject(); // ponds
|
||||
|
||||
createIndex.startObject("neatline").field("type", "geo_shape").endObject(); // map_neatlines
|
||||
createIndex.startObject("neatline").field("type", "shape").endObject(); // map_neatlines
|
||||
|
||||
}
|
||||
createIndex.endObject();
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
city,region,region_point,location,shape
|
||||
Mountain View,Americas,POINT(-105.2551 54.5260),POINT (-122.083843 37.386483),POINT (-122.083843 37.386483)
|
||||
Chicago,Americas,POINT(-105.2551 54.5260),POINT (-87.637874 41.888783),POINT (-87.637874 41.888783)
|
||||
New York,Americas,POINT(-105.2551 54.5260),POINT (-73.990027 40.745171),POINT (-73.990027 40.745171)
|
||||
San Francisco,Americas,POINT(-105.2551 54.5260),POINT (-122.394228 37.789541),POINT (-122.394228 37.789541)
|
||||
Phoenix,Americas,POINT(-105.2551 54.5260),POINT (-111.973505 33.376242),POINT (-111.973505 33.376242)
|
||||
Amsterdam,Europe,POINT(15.2551 54.5260),POINT (4.850312 52.347557),POINT (4.850312 52.347557)
|
||||
Berlin,Europe,POINT(15.2551 54.5260),POINT (13.390889 52.486701),POINT (13.390889 52.486701)
|
||||
Munich,Europe,POINT(15.2551 54.5260),POINT (11.537505 48.146321),POINT (11.537505 48.146321)
|
||||
London,Europe,POINT(15.2551 54.5260),POINT (-0.121672 51.510871),POINT (-0.121672 51.510871)
|
||||
Paris,Europe,POINT(15.2551 54.5260),POINT (2.351773 48.845538),POINT (2.351773 48.845538)
|
||||
Singapore,Asia,POINT(100.6197 34.0479),POINT (103.855535 1.295868),POINT (103.855535 1.295868)
|
||||
Hong Kong,Asia,POINT(100.6197 34.0479),POINT (114.183925 22.281397),POINT (114.183925 22.281397)
|
||||
Seoul,Asia,POINT(100.6197 34.0479),POINT (127.060851 37.509132),POINT (127.060851 37.509132)
|
||||
Tokyo,Asia,POINT(100.6197 34.0479),POINT (139.76402225 35.669616),POINT (139.76402225 35.669616)
|
||||
Sydney,Asia,POINT(100.6197 34.0479),POINT (151.208629 -33.863385),POINT (151.208629 -33.863385)
|
||||
city,region,region_point,location,geoshape,shape
|
||||
Mountain View,Americas,POINT(-105.2551 54.5260),POINT (-122.083843 37.386483),POINT (-122.083843 37.386483)),POINT (-122.083843 37.386483)
|
||||
Chicago,Americas,POINT(-105.2551 54.5260),POINT (-87.637874 41.888783),POINT (-87.637874 41.888783),POINT (-87.637874 41.888783)
|
||||
New York,Americas,POINT(-105.2551 54.5260),POINT (-73.990027 40.745171),POINT (-73.990027 40.745171),POINT (-73.990027 40.745171)
|
||||
San Francisco,Americas,POINT(-105.2551 54.5260),POINT (-122.394228 37.789541),POINT (-122.394228 37.789541),POINT (-122.394228 37.789541)
|
||||
Phoenix,Americas,POINT(-105.2551 54.5260),POINT (-111.973505 33.376242),POINT (-111.973505 33.376242),POINT (-111.973505 33.376242)
|
||||
Amsterdam,Europe,POINT(15.2551 54.5260),POINT (4.850312 52.347557),POINT (4.850312 52.347557),POINT (4.850312 52.347557)
|
||||
Berlin,Europe,POINT(15.2551 54.5260),POINT (13.390889 52.486701),POINT (13.390889 52.486701),POINT (13.390889 52.486701)
|
||||
Munich,Europe,POINT(15.2551 54.5260),POINT (11.537505 48.146321),POINT (11.537505 48.146321),POINT (11.537505 48.146321)
|
||||
London,Europe,POINT(15.2551 54.5260),POINT (-0.121672 51.510871),POINT (-0.121672 51.510871),POINT (-0.121672 51.510871)
|
||||
Paris,Europe,POINT(15.2551 54.5260),POINT (2.351773 48.845538),POINT (2.351773 48.845538),POINT (2.351773 48.845538)
|
||||
Singapore,Asia,POINT(100.6197 34.0479),POINT (103.855535 1.295868),POINT (103.855535 1.295868),POINT (103.855535 1.295868)
|
||||
Hong Kong,Asia,POINT(100.6197 34.0479),POINT (114.183925 22.281397),POINT (114.183925 22.281397),POINT (114.183925 22.281397)
|
||||
Seoul,Asia,POINT(100.6197 34.0479),POINT (127.060851 37.509132),POINT (127.060851 37.509132),POINT (127.060851 37.509132)
|
||||
Tokyo,Asia,POINT(100.6197 34.0479),POINT (139.76402225 35.669616),POINT (139.76402225 35.669616),POINT (139.76402225 35.669616)
|
||||
Sydney,Asia,POINT(100.6197 34.0479),POINT (151.208629 -33.863385),POINT (151.208629 -33.863385),POINT (151.208629 -33.863385)
|
||||
|
|
|
|
@ -1,33 +1,33 @@
|
|||
{"index":{"_id": "1"}}
|
||||
{"region": "Americas", "city": "Mountain View", "location": {"lat":"37.386483", "lon":"-122.083843"}, "location_no_dv": {"lat":"37.386483", "lon":"-122.083843"}, "shape": "POINT (-122.083843 37.386483 30)", "region_point": "POINT(-105.2551 54.5260)"}
|
||||
{"region": "Americas", "city": "Mountain View", "location": {"lat":"37.386483", "lon":"-122.083843"}, "location_no_dv": {"lat":"37.386483", "lon":"-122.083843"}, "geoshape": "POINT (-122.083843 37.386483 30)", "shape": "POINT (-122.083843 37.386483 30)", "region_point": "POINT(-105.2551 54.5260)"}
|
||||
{"index":{"_id": "2"}}
|
||||
{"region": "Americas", "city": "Chicago", "location": [-87.637874, 41.888783], "location_no_dv": [-87.637874, 41.888783], "shape": {"type" : "point", "coordinates" : [-87.637874, 41.888783, 181]}, "region_point": "POINT(-105.2551 54.5260)"}
|
||||
{"region": "Americas", "city": "Chicago", "location": [-87.637874, 41.888783], "location_no_dv": [-87.637874, 41.888783], "geoshape": {"type" : "point", "coordinates" : [-87.637874, 41.888783, 181]}, "shape": {"type" : "point", "coordinates" : [-87.637874, 41.888783, 181]}, "region_point": "POINT(-105.2551 54.5260)"}
|
||||
{"index":{"_id": "3"}}
|
||||
{"region": "Americas", "city": "New York", "location": "40.745171,-73.990027", "location_no_dv": "40.745171,-73.990027", "shape": "POINT (-73.990027 40.745171 10)", "region_point": "POINT(-105.2551 54.5260)"}
|
||||
{"region": "Americas", "city": "New York", "location": "40.745171,-73.990027", "location_no_dv": "40.745171,-73.990027", "geoshape": "POINT (-73.990027 40.745171 10)", "shape": "POINT (-73.990027 40.745171 10)", "region_point": "POINT(-105.2551 54.5260)"}
|
||||
{"index":{"_id": "4"}}
|
||||
{"region": "Americas", "city": "San Francisco", "location": "37.789541,-122.394228", "location_no_dv": "37.789541,-122.394228", "shape": "POINT (-122.394228 37.789541 16)", "region_point": "POINT(-105.2551 54.5260)"}
|
||||
{"region": "Americas", "city": "San Francisco", "location": "37.789541,-122.394228", "location_no_dv": "37.789541,-122.394228", "geoshape": "POINT (-122.394228 37.789541 16)", "shape": "POINT (-122.394228 37.789541 16)", "region_point": "POINT(-105.2551 54.5260)"}
|
||||
{"index":{"_id": "5"}}
|
||||
{"region": "Americas", "city": "Phoenix", "location": "33.376242,-111.973505", "location_no_dv": "33.376242,-111.973505", "shape": "POINT (-111.973505 33.376242 331)", "region_point": "POINT(-105.2551 54.5260)"}
|
||||
{"region": "Americas", "city": "Phoenix", "location": "33.376242,-111.973505", "location_no_dv": "33.376242,-111.973505", "geoshape": "POINT (-111.973505 33.376242 331)", "shape": "POINT (-111.973505 33.376242 331)", "region_point": "POINT(-105.2551 54.5260)"}
|
||||
{"index":{"_id": "6"}}
|
||||
{"region": "Europe", "city": "Amsterdam", "location": "52.347557,4.850312", "location_no_dv": "52.347557,4.850312", "shape": "POINT (4.850312 52.347557 2)", "region_point": "POINT(15.2551 54.5260)"}
|
||||
{"region": "Europe", "city": "Amsterdam", "location": "52.347557,4.850312", "location_no_dv": "52.347557,4.850312", "geoshape": "POINT (4.850312 52.347557 2)", "shape": "POINT (4.850312 52.347557 2)", "region_point": "POINT(15.2551 54.5260)"}
|
||||
{"index":{"_id": "7"}}
|
||||
{"region": "Europe", "city": "Berlin", "location": "52.486701,13.390889", "location_no_dv": "52.486701,13.390889", "shape": "POINT (13.390889 52.486701 34)", "region_point": "POINT(15.2551 54.5260)"}
|
||||
{"region": "Europe", "city": "Berlin", "location": "52.486701,13.390889", "location_no_dv": "52.486701,13.390889", "geoshape": "POINT (13.390889 52.486701 34)", "shape": "POINT (13.390889 52.486701 34)", "region_point": "POINT(15.2551 54.5260)"}
|
||||
{"index":{"_id": "8"}}
|
||||
{"region": "Europe", "city": "Munich", "location": "48.146321,11.537505", "location_no_dv": "48.146321,11.537505", "shape": "POINT (11.537505 48.146321 519)", "region_point": "POINT(15.2551 54.5260)"}
|
||||
{"region": "Europe", "city": "Munich", "location": "48.146321,11.537505", "location_no_dv": "48.146321,11.537505", "geoshape": "POINT (11.537505 48.146321 519)", "shape": "POINT (11.537505 48.146321 519)", "region_point": "POINT(15.2551 54.5260)"}
|
||||
{"index":{"_id": "9"}}
|
||||
{"region": "Europe", "city": "London", "location": "51.510871,-0.121672", "location_no_dv": "51.510871,-0.121672", "shape": "POINT (-0.121672 51.510871 11)", "region_point": "POINT(15.2551 54.5260)"}
|
||||
{"region": "Europe", "city": "London", "location": "51.510871,-0.121672", "location_no_dv": "51.510871,-0.121672", "geoshape": "POINT (-0.121672 51.510871 11)", "shape": "POINT (-0.121672 51.510871 11)", "region_point": "POINT(15.2551 54.5260)"}
|
||||
{"index":{"_id": "10"}}
|
||||
{"region": "Europe", "city": "Paris", "location": "48.845538,2.351773", "location_no_dv": "48.845538,2.351773", "shape": "POINT (2.351773 48.845538 35)", "region_point": "POINT(15.2551 54.5260)"}
|
||||
{"region": "Europe", "city": "Paris", "location": "48.845538,2.351773", "location_no_dv": "48.845538,2.351773", "geoshape": "POINT (2.351773 48.845538 35)", "shape": "POINT (2.351773 48.845538 35)", "region_point": "POINT(15.2551 54.5260)"}
|
||||
{"index":{"_id": "11"}}
|
||||
{"region": "Asia", "city": "Singapore", "location": "1.295868,103.855535", "location_no_dv": "1.295868,103.855535", "shape": "POINT (103.855535 1.295868 15)", "region_point": "POINT(100.6197 34.0479)"}
|
||||
{"region": "Asia", "city": "Singapore", "location": "1.295868,103.855535", "location_no_dv": "1.295868,103.855535", "geoshape": "POINT (103.855535 1.295868 15)", "shape": "POINT (103.855535 1.295868 15)", "region_point": "POINT(100.6197 34.0479)"}
|
||||
{"index":{"_id": "12"}}
|
||||
{"region": "Asia", "city": "Hong Kong", "location": "22.281397,114.183925", "location_no_dv": "22.281397,114.183925", "shape": "POINT (114.183925 22.281397 552)", "region_point": "POINT(100.6197 34.0479)"}
|
||||
{"region": "Asia", "city": "Hong Kong", "location": "22.281397,114.183925", "location_no_dv": "22.281397,114.183925", "geoshape": "POINT (114.183925 22.281397 552)", "shape": "POINT (114.183925 22.281397 552)", "region_point": "POINT(100.6197 34.0479)"}
|
||||
{"index":{"_id": "13"}}
|
||||
{"region": "Asia", "city": "Seoul", "location": "37.509132,127.060851", "location_no_dv": "37.509132,127.060851", "shape": "POINT (127.060851 37.509132 38)", "region_point": "POINT(100.6197 34.0479)"}
|
||||
{"region": "Asia", "city": "Seoul", "location": "37.509132,127.060851", "location_no_dv": "37.509132,127.060851", "geoshape": "POINT (127.060851 37.509132 38)", "shape": "POINT (127.060851 37.509132 38)", "region_point": "POINT(100.6197 34.0479)"}
|
||||
{"index":{"_id": "14"}}
|
||||
{"region": "Asia", "city": "Tokyo", "location": "35.669616,139.76402225", "location_no_dv": "35.669616,139.76402225", "shape": "POINT (139.76402225 35.669616 40)", "region_point": "POINT(100.6197 34.0479)"}
|
||||
{"region": "Asia", "city": "Tokyo", "location": "35.669616,139.76402225", "location_no_dv": "35.669616,139.76402225", "geoshape": "POINT (139.76402225 35.669616 40)", "shape": "POINT (139.76402225 35.669616 40)", "region_point": "POINT(100.6197 34.0479)"}
|
||||
{"index":{"_id": "15"}}
|
||||
{"region": "Asia", "city": "Sydney", "location": "-33.863385,151.208629", "location_no_dv": "-33.863385,151.208629", "shape": "POINT (151.208629 -33.863385 100)", "region_point": "POINT(100.6197 34.0479)"}
|
||||
{"region": "Asia", "city": "Sydney", "location": "-33.863385,151.208629", "location_no_dv": "-33.863385,151.208629", "geoshape": "POINT (151.208629 -33.863385 100)", "shape": "POINT (151.208629 -33.863385 100)", "region_point": "POINT(100.6197 34.0479)"}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,42 +16,43 @@ DESCRIBE "geo";
|
|||
|
||||
column:s | type:s | mapping:s
|
||||
city | VARCHAR | keyword
|
||||
geoshape | GEOMETRY | geo_shape
|
||||
location | GEOMETRY | geo_point
|
||||
location_no_dv | GEOMETRY | geo_point
|
||||
region | VARCHAR | keyword
|
||||
region_point | VARCHAR | keyword
|
||||
shape | GEOMETRY | geo_shape
|
||||
shape | GEOMETRY | shape
|
||||
;
|
||||
|
||||
// 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
|
||||
|
||||
selectAllPointsAsStrings
|
||||
SELECT city, CAST(location AS STRING) location, CAST(location_no_dv AS STRING) location_no_dv, CAST(shape AS STRING) shape, region FROM "geo" ORDER BY "city";
|
||||
SELECT city, CAST(location AS STRING) location, CAST(location_no_dv AS STRING) location_no_dv, CAST(geoshape AS STRING) geoshape, CAST(shape AS STRING) shape, region FROM "geo" ORDER BY "city";
|
||||
|
||||
city:s | location:s | location_no_dv:s | shape:s | region:s
|
||||
Amsterdam |point (4.850311987102032 52.347556999884546) |point (4.850312 52.347557) |point (4.850312 52.347557 2.0) |Europe
|
||||
Berlin |point (13.390888944268227 52.48670099303126) |point (13.390889 52.486701) |point (13.390889 52.486701 34.0) |Europe
|
||||
Chicago |point (-87.63787407428026 41.888782968744636) |point (-87.637874 41.888783) |point (-87.637874 41.888783 181.0) |Americas
|
||||
Hong Kong |point (114.18392493389547 22.28139698971063) |point (114.183925 22.281397) |point (114.183925 22.281397 552.0) |Asia
|
||||
London |point (-0.12167204171419144 51.51087098289281)|point (-0.121672 51.510871) |point (-0.121672 51.510871 11.0) |Europe
|
||||
Mountain View |point (-122.08384302444756 37.38648299127817) |point (-122.083843 37.386483) |point (-122.083843 37.386483 30.0) |Americas
|
||||
Munich |point (11.537504978477955 48.14632098656148) |point (11.537505 48.146321) |point (11.537505 48.146321 519.0) |Europe
|
||||
New York |point (-73.9900270756334 40.74517097789794) |point (-73.990027 40.745171) |point (-73.990027 40.745171 10.0) |Americas
|
||||
Paris |point (2.3517729341983795 48.84553796611726) |point (2.351773 48.845538) |point (2.351773 48.845538 35.0) |Europe
|
||||
Phoenix |point (-111.97350500151515 33.37624196894467) |point (-111.973505 33.376242) |point (-111.973505 33.376242 331.0) |Americas
|
||||
San Francisco |point (-122.39422800019383 37.789540970698) |point (-122.394228 37.789541) |point (-122.394228 37.789541 16.0) |Americas
|
||||
Seoul |point (127.06085099838674 37.50913198571652) |point (127.060851 37.509132) |point (127.060851 37.509132 38.0) |Asia
|
||||
Singapore |point (103.8555349688977 1.2958679627627134) |point (103.855535 1.295868) |point (103.855535 1.295868 15.0) |Asia
|
||||
Sydney |point (151.20862897485495 -33.863385021686554)|point (151.208629 -33.863385) |point (151.208629 -33.863385 100.0) |Asia
|
||||
Tokyo |point (139.76402222178876 35.66961596254259) |point (139.76402225 35.669616)|point (139.76402225 35.669616 40.0) |Asia
|
||||
city:s | location:s | location_no_dv:s | geoshape:s | shape:s | region:s
|
||||
Amsterdam |point (4.850311987102032 52.347556999884546) |point (4.850312 52.347557) |point (4.850312 52.347557 2.0) |point (4.850312 52.347557 2.0) |Europe
|
||||
Berlin |point (13.390888944268227 52.48670099303126) |point (13.390889 52.486701) |point (13.390889 52.486701 34.0) |point (13.390889 52.486701 34.0) |Europe
|
||||
Chicago |point (-87.63787407428026 41.888782968744636) |point (-87.637874 41.888783) |point (-87.637874 41.888783 181.0) |point (-87.637874 41.888783 181.0) |Americas
|
||||
Hong Kong |point (114.18392493389547 22.28139698971063) |point (114.183925 22.281397) |point (114.183925 22.281397 552.0) |point (114.183925 22.281397 552.0) |Asia
|
||||
London |point (-0.12167204171419144 51.51087098289281)|point (-0.121672 51.510871) |point (-0.121672 51.510871 11.0) |point (-0.121672 51.510871 11.0) |Europe
|
||||
Mountain View |point (-122.08384302444756 37.38648299127817) |point (-122.083843 37.386483) |point (-122.083843 37.386483 30.0) |point (-122.083843 37.386483 30.0) |Americas
|
||||
Munich |point (11.537504978477955 48.14632098656148) |point (11.537505 48.146321) |point (11.537505 48.146321 519.0) |point (11.537505 48.146321 519.0) |Europe
|
||||
New York |point (-73.9900270756334 40.74517097789794) |point (-73.990027 40.745171) |point (-73.990027 40.745171 10.0) |point (-73.990027 40.745171 10.0) |Americas
|
||||
Paris |point (2.3517729341983795 48.84553796611726) |point (2.351773 48.845538) |point (2.351773 48.845538 35.0) |point (2.351773 48.845538 35.0) |Europe
|
||||
Phoenix |point (-111.97350500151515 33.37624196894467) |point (-111.973505 33.376242) |point (-111.973505 33.376242 331.0)|point (-111.973505 33.376242 331.0)|Americas
|
||||
San Francisco |point (-122.39422800019383 37.789540970698) |point (-122.394228 37.789541) |point (-122.394228 37.789541 16.0) |point (-122.394228 37.789541 16.0) |Americas
|
||||
Seoul |point (127.06085099838674 37.50913198571652) |point (127.060851 37.509132) |point (127.060851 37.509132 38.0) |point (127.060851 37.509132 38.0) |Asia
|
||||
Singapore |point (103.8555349688977 1.2958679627627134) |point (103.855535 1.295868) |point (103.855535 1.295868 15.0) |point (103.855535 1.295868 15.0) |Asia
|
||||
Sydney |point (151.20862897485495 -33.863385021686554)|point (151.208629 -33.863385) |point (151.208629 -33.863385 100.0)|point (151.208629 -33.863385 100.0)|Asia
|
||||
Tokyo |point (139.76402222178876 35.66961596254259) |point (139.76402225 35.669616)|point (139.76402225 35.669616 40.0)|point (139.76402225 35.669616 40.0)|Asia
|
||||
;
|
||||
|
||||
// TODO: Both shape and location contain the same data for now, we should change it later to make things more interesting
|
||||
selectAllPointsAsWKT
|
||||
SELECT city, ST_ASWKT(location) location_wkt, ST_ASWKT(shape) shape_wkt, region FROM "geo" ORDER BY "city";
|
||||
SELECT city, ST_ASWKT(location) location_wkt, ST_ASWKT(geoshape) geoshape_wkt, region FROM "geo" ORDER BY "city";
|
||||
|
||||
city:s | location_wkt:s | shape_wkt:s | region:s
|
||||
city:s | location_wkt:s | geoshape_wkt:s | region:s
|
||||
Amsterdam |point (4.850311987102032 52.347556999884546) |point (4.850312 52.347557 2.0) |Europe
|
||||
Berlin |point (13.390888944268227 52.48670099303126) |point (13.390889 52.486701 34.0) |Europe
|
||||
Chicago |point (-87.63787407428026 41.888782968744636) |point (-87.637874 41.888783 181.0) |Americas
|
||||
|
@ -262,7 +263,7 @@ SELECT COUNT(*) cnt, FLOOR(ST_Y(location)/45) north, FLOOR(ST_X(location)/90) ea
|
|||
;
|
||||
|
||||
selectFilterByXOfLocation
|
||||
SELECT city, ST_X(shape) x, ST_Y(shape) y, ST_Z(shape) z, ST_X(location) lx, ST_Y(location) ly FROM geo WHERE lx > 0 ORDER BY ly;
|
||||
SELECT city, ST_X(geoshape) x, ST_Y(geoshape) y, ST_Z(geoshape) z, ST_X(location) lx, ST_Y(location) ly FROM geo WHERE lx > 0 ORDER BY ly;
|
||||
|
||||
city:s | x:d | y:d | z:d | lx:d | ly:d
|
||||
Sydney |151.208629 |-33.863385 |100.0 |151.20862897485495|-33.863385021686554
|
||||
|
|
|
@ -17,12 +17,15 @@
|
|||
"type": "geo_point",
|
||||
"doc_values": "false"
|
||||
},
|
||||
"shape": {
|
||||
"geoshape": {
|
||||
"type": "geo_shape"
|
||||
},
|
||||
"region_point": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"shape": {
|
||||
"type": "shape"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ CREATE TABLE "geo" (
|
|||
"region" VARCHAR(50),
|
||||
"region_point" VARCHAR(50),
|
||||
"location" POINT,
|
||||
"geoshape" GEOMETRY,
|
||||
"shape" GEOMETRY
|
||||
)
|
||||
AS SELECT * FROM CSVREAD('classpath:/geo/geo.csv');
|
||||
|
|
|
@ -19,18 +19,18 @@ address | VARCHAR | text
|
|||
address.keyword | VARCHAR | keyword
|
||||
aliases | VARCHAR | text
|
||||
aliases.keyword | VARCHAR | keyword
|
||||
boundary | GEOMETRY | geo_shape
|
||||
centerline | GEOMETRY | geo_shape
|
||||
centerlines | GEOMETRY | geo_shape
|
||||
boundary | GEOMETRY | shape
|
||||
centerline | GEOMETRY | shape
|
||||
centerlines | GEOMETRY | shape
|
||||
fid | INTEGER | integer
|
||||
footprint | GEOMETRY | geo_shape
|
||||
footprint | GEOMETRY | shape
|
||||
name | VARCHAR | text
|
||||
name.keyword | VARCHAR | keyword
|
||||
neatline | GEOMETRY | geo_shape
|
||||
neatline | GEOMETRY | shape
|
||||
num_lanes | INTEGER | integer
|
||||
ogc_type | VARCHAR | keyword
|
||||
position | GEOMETRY | geo_shape
|
||||
shore | GEOMETRY | geo_shape
|
||||
shores | GEOMETRY | geo_shape
|
||||
position | GEOMETRY | shape
|
||||
shore | GEOMETRY | shape
|
||||
shores | GEOMETRY | shape
|
||||
type | VARCHAR | keyword
|
||||
;
|
||||
|
|
|
@ -7,9 +7,10 @@ SYS COLUMNS TABLE LIKE 'geo';
|
|||
|
||||
TABLE_CAT:s | TABLE_SCHEM:s| TABLE_NAME:s | COLUMN_NAME:s | DATA_TYPE:i | TYPE_NAME:s | COLUMN_SIZE:i|BUFFER_LENGTH:i|DECIMAL_DIGITS:i|NUM_PREC_RADIX:i| NULLABLE:i| REMARKS:s | COLUMN_DEF:s |SQL_DATA_TYPE:i|SQL_DATETIME_SUB:i|CHAR_OCTET_LENGTH:i|ORDINAL_POSITION:i|IS_NULLABLE:s|SCOPE_CATALOG:s|SCOPE_SCHEMA:s|SCOPE_TABLE:s|SOURCE_DATA_TYPE:sh|IS_AUTOINCREMENT:s|IS_GENERATEDCOLUMN:s
|
||||
integTest|null |geo |city |12 |KEYWORD |32766 |2147483647 |null |null |1 |null |null |12 |0 |2147483647 |1 |YES |null |null |null |null |NO |NO
|
||||
integTest|null |geo |location |114 |GEO_POINT |58 |16 |null |null |1 |null |null |114 |0 |null |2 |YES |null |null |null |null |NO |NO
|
||||
integTest|null |geo |location_no_dv |114 |GEO_POINT |58 |16 |null |null |1 |null |null |114 |0 |null |3 |YES |null |null |null |null |NO |NO
|
||||
integTest|null |geo |region |12 |KEYWORD |32766 |2147483647 |null |null |1 |null |null |12 |0 |2147483647 |4 |YES |null |null |null |null |NO |NO
|
||||
integTest|null |geo |region_point |12 |KEYWORD |32766 |2147483647 |null |null |1 |null |null |12 |0 |2147483647 |5 |YES |null |null |null |null |NO |NO
|
||||
integTest|null |geo |shape |114 |GEO_SHAPE |2147483647 |2147483647 |null |null |1 |null |null |114 |0 |null |6 |YES |null |null |null |null |NO |NO
|
||||
integTest|null |geo |geoshape |114 |GEO_SHAPE |2147483647 |2147483647 |null |null |1 |null |null |114 |0 |null |2 |YES |null |null |null |null |NO |NO
|
||||
integTest|null |geo |location |114 |GEO_POINT |58 |16 |null |null |1 |null |null |114 |0 |null |3 |YES |null |null |null |null |NO |NO
|
||||
integTest|null |geo |location_no_dv |114 |GEO_POINT |58 |16 |null |null |1 |null |null |114 |0 |null |4 |YES |null |null |null |null |NO |NO
|
||||
integTest|null |geo |region |12 |KEYWORD |32766 |2147483647 |null |null |1 |null |null |12 |0 |2147483647 |5 |YES |null |null |null |null |NO |NO
|
||||
integTest|null |geo |region_point |12 |KEYWORD |32766 |2147483647 |null |null |1 |null |null |12 |0 |2147483647 |6 |YES |null |null |null |null |NO |NO
|
||||
integTest|null |geo |shape |114 |SHAPE |2147483647 |2147483647 |null |null |1 |null |null |114 |0 |null |7 |YES |null |null |null |null |NO |NO
|
||||
;
|
|
@ -69,6 +69,7 @@ import static org.elasticsearch.xpack.sql.stats.FeatureMetric.LOCAL;
|
|||
import static org.elasticsearch.xpack.sql.stats.FeatureMetric.ORDERBY;
|
||||
import static org.elasticsearch.xpack.sql.stats.FeatureMetric.WHERE;
|
||||
import static org.elasticsearch.xpack.sql.type.DataType.GEO_SHAPE;
|
||||
import static org.elasticsearch.xpack.sql.type.DataType.SHAPE;
|
||||
import static org.elasticsearch.xpack.sql.util.CollectionUtils.combine;
|
||||
|
||||
/**
|
||||
|
@ -77,7 +78,7 @@ import static org.elasticsearch.xpack.sql.util.CollectionUtils.combine;
|
|||
*/
|
||||
public final class Verifier {
|
||||
private final Metrics metrics;
|
||||
|
||||
|
||||
public Verifier(Metrics metrics) {
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
@ -254,7 +255,7 @@ public final class Verifier {
|
|||
failures.addAll(localFailures);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// gather metrics
|
||||
if (failures.isEmpty()) {
|
||||
BitSet b = new BitSet(FeatureMetric.values().length);
|
||||
|
@ -631,7 +632,7 @@ public final class Verifier {
|
|||
if (Functions.isAggregate(e)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// left without leaves which have to match; if not there's a failure
|
||||
// make sure to match directly on the expression and not on the tree
|
||||
// (since otherwise exp might match the function argument which would be incorrect)
|
||||
|
@ -644,7 +645,7 @@ public final class Verifier {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private static void checkGroupingFunctionInGroupBy(LogicalPlan p, Set<Failure> localFailures) {
|
||||
// check if the query has a grouping function (Histogram) but no GROUP BY
|
||||
if (p instanceof Project) {
|
||||
|
@ -734,14 +735,14 @@ public final class Verifier {
|
|||
fail(nested.get(0), "Grouping isn't (yet) compatible with nested fields " + new AttributeSet(nested).names()));
|
||||
nested.clear();
|
||||
}
|
||||
|
||||
|
||||
// check in having
|
||||
p.forEachDown(f -> {
|
||||
if (f.child() instanceof Aggregate) {
|
||||
f.condition().forEachUp(match, FieldAttribute.class);
|
||||
}
|
||||
}, Filter.class);
|
||||
|
||||
|
||||
if (!nested.isEmpty()) {
|
||||
localFailures.add(
|
||||
fail(nested.get(0), "HAVING isn't (yet) compatible with nested fields " + new AttributeSet(nested).names()));
|
||||
|
@ -758,6 +759,9 @@ public final class Verifier {
|
|||
if (fa.field().getDataType() == GEO_SHAPE) {
|
||||
localFailures.add(fail(fa, "geo shapes cannot be used for filtering"));
|
||||
}
|
||||
if (fa.field().getDataType() == SHAPE) {
|
||||
localFailures.add(fail(fa, "shapes cannot be used for filtering"));
|
||||
}
|
||||
}, FieldAttribute.class);
|
||||
}, Filter.class);
|
||||
|
||||
|
@ -766,6 +770,9 @@ public final class Verifier {
|
|||
if (fa.field().getDataType() == GEO_SHAPE) {
|
||||
localFailures.add(fail(fa, "geo shapes cannot be used in grouping"));
|
||||
}
|
||||
if (fa.field().getDataType() == SHAPE) {
|
||||
localFailures.add(fail(fa, "shapes cannot be used in grouping"));
|
||||
}
|
||||
}, FieldAttribute.class)), Aggregate.class);
|
||||
|
||||
|
||||
|
@ -774,6 +781,9 @@ public final class Verifier {
|
|||
if (fa.field().getDataType() == GEO_SHAPE) {
|
||||
localFailures.add(fail(fa, "geo shapes cannot be used for sorting"));
|
||||
}
|
||||
if (fa.field().getDataType() == SHAPE) {
|
||||
localFailures.add(fail(fa, "shapes cannot be used for sorting"));
|
||||
}
|
||||
}, FieldAttribute.class)), OrderBy.class);
|
||||
}
|
||||
|
||||
|
@ -831,7 +841,7 @@ public final class Verifier {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}, Pivot.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,6 +190,13 @@ public class FieldHitExtractor implements HitExtractor {
|
|||
throw new SqlIllegalArgumentException("Cannot read geo_shape value [{}] (returned by [{}])", values, fieldName);
|
||||
}
|
||||
}
|
||||
if (dataType == DataType.SHAPE) {
|
||||
try {
|
||||
return new GeoShape(values);
|
||||
} catch (IOException ex) {
|
||||
throw new SqlIllegalArgumentException("Cannot read shape value [{}] (returned by [{}])", values, fieldName);
|
||||
}
|
||||
}
|
||||
if (values instanceof Map) {
|
||||
throw new SqlIllegalArgumentException("Objects (returned by [{}]) are not supported", fieldName);
|
||||
}
|
||||
|
@ -198,7 +205,7 @@ public class FieldHitExtractor implements HitExtractor {
|
|||
return DateUtils.asDateTime(Long.parseLong(values.toString()), zoneId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The Jackson json parser can generate for numerics - Integers, Longs, BigIntegers (if Long is not enough)
|
||||
// and BigDecimal (if Double is not enough)
|
||||
if (values instanceof Number || values instanceof String || values instanceof Boolean) {
|
||||
|
@ -266,7 +273,7 @@ public class FieldHitExtractor implements HitExtractor {
|
|||
for (int i = idx + 1; i < path.length; i++) {
|
||||
sj.add(path[i]);
|
||||
Object node = subMap.get(sj.toString());
|
||||
|
||||
|
||||
if (node instanceof List) {
|
||||
List listOfValues = (List) node;
|
||||
// we can only do this optimization until the last element of our pass since geo points are using arrays
|
||||
|
@ -281,7 +288,7 @@ public class FieldHitExtractor implements HitExtractor {
|
|||
return unwrapMultiValue(node);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (node instanceof Map) {
|
||||
if (i < path.length - 1) {
|
||||
// Add the sub-map to the queue along with the current path index
|
||||
|
@ -318,7 +325,7 @@ public class FieldHitExtractor implements HitExtractor {
|
|||
public String fieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
|
||||
public String fullFieldName() {
|
||||
return fullFieldName;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class GeoShape implements ToXContentFragment, NamedWriteable {
|
|||
try {
|
||||
shape = parse(value);
|
||||
} catch (ParseException ex) {
|
||||
throw new SqlIllegalArgumentException("Cannot parse [" + value + "] as a geo_shape value", ex);
|
||||
throw new SqlIllegalArgumentException("Cannot parse [" + value + "] as a geo_shape or shape value", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class GeoShape implements ToXContentFragment, NamedWriteable {
|
|||
try {
|
||||
shape = parse(value);
|
||||
} catch (ParseException ex) {
|
||||
throw new SqlIllegalArgumentException("Cannot parse [" + value + "] as a geo_shape value", ex);
|
||||
throw new SqlIllegalArgumentException("Cannot parse [" + value + "] as a geo_shape or shape value", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,8 @@ public enum DataType {
|
|||
GEO_POINT( ExtTypes.GEOMETRY, Double.BYTES*2, Integer.MAX_VALUE, 25 * 2 + 8, false, false, false),
|
||||
// IP can be v4 or v6. The latter has 2^128 addresses or 340,282,366,920,938,463,463,374,607,431,768,211,456
|
||||
// aka 39 chars
|
||||
SHAPE( ExtTypes.GEOMETRY, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, false, false, false),
|
||||
// display size = 2 doubles + len("POINT( )")
|
||||
IP( "ip", JDBCType.VARCHAR, 39, 39, 0, false, false, true),
|
||||
//
|
||||
// INTERVALS
|
||||
|
@ -254,7 +256,7 @@ public enum DataType {
|
|||
}
|
||||
|
||||
public boolean isGeo() {
|
||||
return this == GEO_POINT || this == GEO_SHAPE;
|
||||
return this == GEO_POINT || this == GEO_SHAPE || this == SHAPE;
|
||||
}
|
||||
|
||||
public boolean isDateBased() {
|
||||
|
@ -268,7 +270,7 @@ public enum DataType {
|
|||
public boolean isDateOrTimeBased() {
|
||||
return isDateBased() || isTimeBased();
|
||||
}
|
||||
|
||||
|
||||
// data type extract-able from _source or from docvalue_fields
|
||||
public boolean isFromDocValuesOnly() {
|
||||
return this == KEYWORD // because of ignore_above. Extracting this from _source wouldn't make sense if it wasn't indexed at all.
|
||||
|
@ -276,13 +278,14 @@ public enum DataType {
|
|||
|| this == DATETIME
|
||||
|| this == SCALED_FLOAT // because of scaling_factor
|
||||
|| this == GEO_POINT
|
||||
|| this == GEO_SHAPE;
|
||||
|| this == GEO_SHAPE
|
||||
|| this == SHAPE;
|
||||
}
|
||||
|
||||
|
||||
public static DataType fromOdbcType(String odbcType) {
|
||||
return ODBC_TO_ES.get(odbcType);
|
||||
}
|
||||
|
||||
|
||||
public static DataType fromSqlOrEsType(String typeName) {
|
||||
return SQL_TO_ES.get(typeName.toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
@ -305,7 +308,7 @@ public enum DataType {
|
|||
public String format() {
|
||||
return isDateOrTimeBased() ? DateUtils.DATE_PARSE_FORMAT : null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the appropriate NumberType enum corresponding to this es type
|
||||
*/
|
||||
|
|
|
@ -396,7 +396,7 @@ public class FieldHitExtractorTests extends AbstractSqlWireSerializingTestCase<F
|
|||
SqlException ex = expectThrows(SqlException.class, () -> fe.extractFromSource(map));
|
||||
assertThat(ex.getMessage(), is("Multiple values (returned by [a.b.c.d.e.f.g]) are not supported"));
|
||||
}
|
||||
|
||||
|
||||
public void testFieldsWithSingleValueArrayAsSubfield() {
|
||||
FieldHitExtractor fe = getFieldHitExtractor("a.b", false);
|
||||
Object value = randomNonNullValue();
|
||||
|
@ -405,7 +405,7 @@ public class FieldHitExtractorTests extends AbstractSqlWireSerializingTestCase<F
|
|||
map.put("a", singletonList(singletonMap("b", value)));
|
||||
assertEquals(value, fe.extractFromSource(map));
|
||||
}
|
||||
|
||||
|
||||
public void testFieldsWithMultiValueArrayAsSubfield() {
|
||||
FieldHitExtractor fe = getFieldHitExtractor("a.b", false);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
@ -414,7 +414,7 @@ public class FieldHitExtractorTests extends AbstractSqlWireSerializingTestCase<F
|
|||
SqlException ex = expectThrows(SqlException.class, () -> fe.extractFromSource(map));
|
||||
assertThat(ex.getMessage(), is("Arrays (returned by [a.b]) are not supported"));
|
||||
}
|
||||
|
||||
|
||||
public void testFieldsWithSingleValueArrayAsSubfield_TwoNestedLists() {
|
||||
FieldHitExtractor fe = getFieldHitExtractor("a.b.c", false);
|
||||
Object value = randomNonNullValue();
|
||||
|
@ -423,7 +423,7 @@ public class FieldHitExtractorTests extends AbstractSqlWireSerializingTestCase<F
|
|||
map.put("a", singletonList(singletonMap("b", singletonList(singletonMap("c", value)))));
|
||||
assertEquals(value, fe.extractFromSource(map));
|
||||
}
|
||||
|
||||
|
||||
public void testFieldsWithMultiValueArrayAsSubfield_ThreeNestedLists() {
|
||||
FieldHitExtractor fe = getFieldHitExtractor("a.b.c", false);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
@ -432,7 +432,7 @@ public class FieldHitExtractorTests extends AbstractSqlWireSerializingTestCase<F
|
|||
SqlException ex = expectThrows(SqlException.class, () -> fe.extractFromSource(map));
|
||||
assertThat(ex.getMessage(), is("Arrays (returned by [a.b.c]) are not supported"));
|
||||
}
|
||||
|
||||
|
||||
public void testFieldsWithSingleValueArrayAsSubfield_TwoNestedLists2() {
|
||||
FieldHitExtractor fe = getFieldHitExtractor("a.b.c", false);
|
||||
Object value = randomNonNullValue();
|
||||
|
@ -462,7 +462,7 @@ public class FieldHitExtractorTests extends AbstractSqlWireSerializingTestCase<F
|
|||
|
||||
public void testGeoShapeExtraction() {
|
||||
String fieldName = randomAlphaOfLength(5);
|
||||
FieldHitExtractor fe = new FieldHitExtractor(fieldName, DataType.GEO_SHAPE, UTC, false);
|
||||
FieldHitExtractor fe = new FieldHitExtractor(fieldName, randomBoolean() ? DataType.GEO_SHAPE : DataType.SHAPE, UTC, false);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(fieldName, "POINT (1 2)");
|
||||
assertEquals(new GeoShape(1, 2), fe.extractFromSource(map));
|
||||
|
@ -474,7 +474,7 @@ public class FieldHitExtractorTests extends AbstractSqlWireSerializingTestCase<F
|
|||
|
||||
public void testMultipleGeoShapeExtraction() {
|
||||
String fieldName = randomAlphaOfLength(5);
|
||||
FieldHitExtractor fe = new FieldHitExtractor(fieldName, DataType.GEO_SHAPE, UTC, false);
|
||||
FieldHitExtractor fe = new FieldHitExtractor(fieldName, randomBoolean() ? DataType.GEO_SHAPE : DataType.SHAPE, UTC, false);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(fieldName, "POINT (1 2)");
|
||||
assertEquals(new GeoShape(1, 2), fe.extractFromSource(map));
|
||||
|
@ -487,7 +487,8 @@ public class FieldHitExtractorTests extends AbstractSqlWireSerializingTestCase<F
|
|||
SqlException ex = expectThrows(SqlException.class, () -> fe.extractFromSource(map2));
|
||||
assertThat(ex.getMessage(), is("Arrays (returned by [" + fieldName + "]) are not supported"));
|
||||
|
||||
FieldHitExtractor lenientFe = new FieldHitExtractor(fieldName, DataType.GEO_SHAPE, UTC, false, true);
|
||||
FieldHitExtractor lenientFe = new FieldHitExtractor(fieldName,
|
||||
randomBoolean() ? DataType.GEO_SHAPE : DataType.SHAPE, UTC, false, true);
|
||||
assertEquals(new GeoShape(1, 2), lenientFe.extractFromSource(map2));
|
||||
}
|
||||
|
||||
|
@ -605,7 +606,7 @@ public class FieldHitExtractorTests extends AbstractSqlWireSerializingTestCase<F
|
|||
() -> new BigDecimal("20012312345621343256123456254.20012312345621343256123456254")));
|
||||
return value.get();
|
||||
}
|
||||
|
||||
|
||||
private void assertFieldHitEquals(Object expected, Object actual) {
|
||||
if (expected instanceof BigDecimal) {
|
||||
// parsing will, by default, build a Double even if the initial value is BigDecimal
|
||||
|
|
|
@ -33,11 +33,11 @@ public class StWkttosqlProcessorTests extends ESTestCase {
|
|||
assertEquals("Cannot parse [some random string] as a geo_shape value", siae.getMessage());
|
||||
|
||||
siae = expectThrows(SqlIllegalArgumentException.class, () -> procPoint.process("point (foo bar)"));
|
||||
assertEquals("Cannot parse [point (foo bar)] as a geo_shape value", siae.getMessage());
|
||||
assertEquals("Cannot parse [point (foo bar)] as a geo_shape or shape value", siae.getMessage());
|
||||
|
||||
|
||||
siae = expectThrows(SqlIllegalArgumentException.class, () -> procPoint.process("point (10 10"));
|
||||
assertEquals("Cannot parse [point (10 10] as a geo_shape value", siae.getMessage());
|
||||
assertEquals("Cannot parse [point (10 10] as a geo_shape or shape value", siae.getMessage());
|
||||
}
|
||||
|
||||
public void testCoerce() {
|
||||
|
|
|
@ -49,7 +49,7 @@ public class SysTypesTests extends ESTestCase {
|
|||
"INTERVAL_YEAR", "INTERVAL_MONTH", "INTERVAL_DAY", "INTERVAL_HOUR", "INTERVAL_MINUTE", "INTERVAL_SECOND",
|
||||
"INTERVAL_YEAR_TO_MONTH", "INTERVAL_DAY_TO_HOUR", "INTERVAL_DAY_TO_MINUTE", "INTERVAL_DAY_TO_SECOND",
|
||||
"INTERVAL_HOUR_TO_MINUTE", "INTERVAL_HOUR_TO_SECOND", "INTERVAL_MINUTE_TO_SECOND",
|
||||
"GEO_SHAPE", "GEO_POINT", "UNSUPPORTED", "OBJECT", "NESTED");
|
||||
"GEO_SHAPE", "GEO_POINT", "SHAPE", "UNSUPPORTED", "OBJECT", "NESTED");
|
||||
|
||||
cmd.execute(session(), wrap(p -> {
|
||||
SchemaRowSet r = (SchemaRowSet) p.rowSet();
|
||||
|
@ -62,7 +62,7 @@ public class SysTypesTests extends ESTestCase {
|
|||
assertFalse(r.column(10, Boolean.class));
|
||||
// no auto-increment
|
||||
assertFalse(r.column(11, Boolean.class));
|
||||
|
||||
|
||||
for (int i = 0; i < r.size(); i++) {
|
||||
assertEquals(names.get(i), r.column(0));
|
||||
r.advanceRow();
|
||||
|
|
Loading…
Reference in New Issue