use of io.crate.types.ArrayType in project crate by crate.
the class CastFunctionTest method test_cast_wkt_point_string_array_to_geo_shape_array.
@Test
public void test_cast_wkt_point_string_array_to_geo_shape_array() {
Symbol funcSymbol = sqlExpressions.asSymbol("['POINT(2 3)']::array(geo_shape)");
assertThat(funcSymbol.valueType(), is(new ArrayType<>(GEO_SHAPE)));
// noinspection unchecked
var geoShapes = (List<Map<String, Object>>) ((Literal<?>) funcSymbol).value();
assertThat(GEO_SHAPE.compare(geoShapes.get(0), Map.of(GeoJSONUtils.TYPE_FIELD, GeoJSONUtils.POINT, GeoJSONUtils.COORDINATES_FIELD, new Double[] { 2.0, 3.0 })), is(0));
}
use of io.crate.types.ArrayType in project crate by crate.
the class SysNodesTableInfoTest method test_column_that_is_a_child_of_an_array_has_array_type_on_select.
@Test
public void test_column_that_is_a_child_of_an_array_has_array_type_on_select() {
var table = SysNodesTableInfo.create();
Reference ref = table.getReference(new ColumnIdent("fs", List.of("data", "path")));
assertThat(ref.valueType(), is(new ArrayType<>(DataTypes.STRING)));
SQLExecutor e = SQLExecutor.builder(clusterService).build();
AnalyzedRelation statement = e.analyze("select fs['data']['path'] from sys.nodes");
assertThat(statement.outputs().get(0).valueType(), is(new ArrayType<>(DataTypes.STRING)));
}
use of io.crate.types.ArrayType in project crate by crate.
the class DocIndexMetadataTest method testCreateTableMappingGenerationAndParsingArrayInsideObject.
@Test
public void testCreateTableMappingGenerationAndParsingArrayInsideObject() throws Exception {
DocIndexMetadata md = getDocIndexMetadataFromStatement("create table t1 (" + "id int primary key," + "details object as (names array(string))" + ") with (number_of_replicas=0)");
DataType type = md.references().get(new ColumnIdent("details", "names")).valueType();
assertThat(type, Matchers.equalTo(new ArrayType(DataTypes.STRING)));
}
use of io.crate.types.ArrayType in project crate by crate.
the class DocIndexMetadataTest method testStringArrayWithFulltextIndex.
@Test
public void testStringArrayWithFulltextIndex() throws Exception {
DocIndexMetadata metadata = getDocIndexMetadataFromStatement("create table t (tags array(string) index using fulltext)");
Reference reference = metadata.columns().iterator().next();
assertThat(reference.valueType(), equalTo(new ArrayType(DataTypes.STRING)));
}
use of io.crate.types.ArrayType in project crate by crate.
the class DocIndexMetadataTest method testNewArrayMapping.
@Test
public void testNewArrayMapping() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject().startObject("_meta").field("primary_keys", "id").endObject().startObject("properties").startObject("id").field("type", "integer").endObject().startObject("title").field("type", "string").field("index", "false").endObject().startObject("array_col").field("type", "array").startObject("inner").field("type", "ip").endObject().endObject().startObject("nested").field("type", "object").startObject("properties").startObject("inner_nested").field("type", "array").startObject("inner").field("type", "date").endObject().endObject().endObject().endObject().endObject().endObject();
IndexMetadata indexMetadata = getIndexMetadata("test1", builder);
DocIndexMetadata docIndexMetadata = newMeta(indexMetadata, "test1");
assertThat(docIndexMetadata.references().get(ColumnIdent.fromPath("array_col")).valueType(), is(new ArrayType(DataTypes.IP)));
assertThat(docIndexMetadata.references().get(ColumnIdent.fromPath("nested.inner_nested")).valueType(), is(new ArrayType(DataTypes.TIMESTAMPZ)));
}
Aggregations