Skip to content

Commit

Permalink
Fixed supported/unsupported types in yaml tests
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtaverner committed Nov 27, 2023
1 parent 045bdda commit 61f9cba
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import org.elasticsearch.index.fielddata.FieldDataContext;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.mapper.AbstractPointGeometryFieldMapper;
import org.elasticsearch.index.mapper.BlockDocValuesReader;
import org.elasticsearch.index.mapper.BlockLoader;
import org.elasticsearch.index.mapper.BlockSourceReader;
import org.elasticsearch.index.mapper.DocumentParserContext;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.GeoShapeFieldMapper;
Expand Down Expand Up @@ -117,6 +120,7 @@ public FieldMapper build(MapperBuilderContext context) {
stored.get(),
hasDocValues.get(),
parser,
nullValue.get(),
meta.get()
);
return new PointFieldMapper(name, ft, multiFieldsBuilder.build(this, context), copyTo, parser, this);
Expand Down Expand Up @@ -182,22 +186,25 @@ public FieldMapper.Builder getMergeBuilder() {
public static class PointFieldType extends AbstractGeometryFieldType<CartesianPoint> implements ShapeQueryable {

private final ShapeQueryPointProcessor queryProcessor;
private final CartesianPoint nullValue;

private PointFieldType(
String name,
boolean indexed,
boolean stored,
boolean hasDocValues,
CartesianPointParser parser,
CartesianPoint nullValue,
Map<String, String> meta
) {
super(name, indexed, stored, hasDocValues, parser, meta);
this.nullValue = nullValue;
this.queryProcessor = new ShapeQueryPointProcessor();
}

// only used in test
public PointFieldType(String name) {
this(name, true, false, true, null, Collections.emptyMap());
this(name, true, false, true, null, null, Collections.emptyMap());
}

@Override
Expand All @@ -224,6 +231,17 @@ public Query shapeQuery(Geometry shape, String fieldName, ShapeRelation relation
protected Function<List<CartesianPoint>, List<Object>> getFormatter(String format) {
return GeometryFormatterFactory.getFormatter(format, p -> new Point(p.getX(), p.getY()));
}

@Override
public BlockLoader blockLoader(BlockLoaderContext blContext) {
if (hasDocValues()) {
return new BlockDocValuesReader.LongsBlockLoader(name());
}
// TODO: Currently we use longs in the compute engine and render to WKT in ESQL
return new BlockSourceReader.LongsBlockLoader(
valueFetcher(blContext.sourcePaths(name()), nullValue, GeometryFormatterFactory.WKT)
);
}
}

/** CartesianPoint parser implementation */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,3 +768,33 @@ geo_point:
- match: { columns.0.type: geo_point }
- length: { values: 1 }
- match: { values.0.0: "POINT (0.9999999403953552 -1.000000024214387)" }

---
cartesian_point:
- do:
indices.create:
index: test
body:
mappings:
properties:
location:
type: point

- do:
bulk:
index: test
refresh: true
body:
- { "index": { } }
- { "location": "POINT(4321 -1234)" }

- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test'
- match: { columns.0.name: location }
- match: { columns.0.type: cartesian_point }
- length: { values: 1 }
- match: { values.0.0: "POINT (4321.0 -1234.0)" }
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ unsupported:
- match: { columns.16.name: name }
- match: { columns.16.type: keyword }
- match: { columns.17.name: point }
- match: { columns.17.type: unsupported }
- match: { columns.17.type: cartesian_point }
- match: { columns.18.name: rank_feature }
- match: { columns.18.type: unsupported }
- match: { columns.19.name: rank_features }
Expand Down Expand Up @@ -252,7 +252,7 @@ unsupported:
- match: { columns.16.name: name }
- match: { columns.16.type: keyword }
- match: { columns.17.name: point }
- match: { columns.17.type: unsupported }
- match: { columns.17.type: cartesian_point }
- match: { columns.18.name: rank_feature }
- match: { columns.18.type: unsupported }
- match: { columns.19.name: rank_features }
Expand Down Expand Up @@ -336,7 +336,7 @@ unsupported with sort:
- match: { columns.16.name: name }
- match: { columns.16.type: keyword }
- match: { columns.17.name: point }
- match: { columns.17.type: unsupported }
- match: { columns.17.type: cartesian_point }
- match: { columns.18.name: rank_feature }
- match: { columns.18.type: unsupported }
- match: { columns.19.name: rank_features }
Expand Down Expand Up @@ -410,7 +410,7 @@ spatial types unsupported in 8.11:
- match: { columns.1.name: geo_point_alias }
- match: { columns.1.type: unsupported }
- match: { columns.2.name: point }
- match: { columns.2.type: unsupported }
- match: { columns.2.type: cartesian_point }
- match: { columns.3.name: geo_shape }
- match: { columns.3.type: unsupported }
- match: { columns.4.name: shape }
Expand Down

0 comments on commit 61f9cba

Please sign in to comment.