use of io.crate.types.ArrayType in project crate by crate.
the class LuceneQueryBuilderTest method prepare.
@Before
public void prepare() throws Exception {
DocTableInfo users = TestingTableInfo.builder(new TableIdent(null, "users"), null).add("name", DataTypes.STRING).add("x", DataTypes.INTEGER).add("d", DataTypes.DOUBLE).add("d_array", new ArrayType(DataTypes.DOUBLE)).add("y_array", new ArrayType(DataTypes.LONG)).add("shape", DataTypes.GEO_SHAPE).add("point", DataTypes.GEO_POINT).build();
TableRelation usersTr = new TableRelation(users);
sources = ImmutableMap.of(new QualifiedName("users"), usersTr);
expressions = new SqlExpressions(sources, usersTr);
builder = new LuceneQueryBuilder(expressions.getInstance(Functions.class));
indexCache = mock(IndexCache.class, Answers.RETURNS_MOCKS.get());
Path tempDir = createTempDir();
Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).put("path.home", tempDir).build();
Index index = new Index(users.ident().indexName());
when(indexCache.indexSettings()).thenReturn(indexSettings);
AnalysisService analysisService = createAnalysisService(indexSettings, index);
mapperService = createMapperService(index, indexSettings, analysisService);
// @formatter:off
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("default").startObject("properties").startObject("name").field("type", "string").endObject().startObject("x").field("type", "integer").endObject().startObject("d").field("type", "double").endObject().startObject("point").field("type", "geo_point").endObject().startObject("shape").field("type", "geo_shape").endObject().startObject("d_array").field("type", "array").startObject("inner").field("type", "double").endObject().endObject().startObject("y_array").field("type", "array").startObject("inner").field("type", "integer").endObject().endObject().endObject().endObject().endObject();
// @formatter:on
mapperService.merge("default", new CompressedXContent(xContentBuilder.bytes()), MapperService.MergeReason.MAPPING_UPDATE, true);
indexFieldDataService = mock(IndexFieldDataService.class);
IndexFieldData geoFieldData = mock(IndexGeoPointFieldData.class);
when(geoFieldData.getFieldNames()).thenReturn(new MappedFieldType.Names("point"));
when(indexFieldDataService.getForField(mapperService.smartNameFieldType("point"))).thenReturn(geoFieldData);
}
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().get(0);
assertThat(reference.valueType(), equalTo((DataType) new ArrayType(DataTypes.STRING)));
}
use of io.crate.types.ArrayType in project crate by crate.
the class ParameterContextTest method testBulkNestedNestedEmpty.
@Test
public void testBulkNestedNestedEmpty() throws Exception {
Object[][] bulkArgs = new Object[][] { new Object[] { new String[][] { new String[0] } }, new Object[] { new String[][] { new String[0] } } };
ParameterContext ctx = new ParameterContext(Row.EMPTY, Rows.of(bulkArgs));
assertThat(ctx.getAsSymbol(0), isLiteral(bulkArgs[0][0], new ArrayType(new ArrayType(DataTypes.UNDEFINED))));
}
use of io.crate.types.ArrayType in project crate by crate.
the class CopyAnalyzerTest method testCopyFromFileUriArray.
@Test
public void testCopyFromFileUriArray() throws Exception {
Object[] files = $("/f1.json", "/f2.json");
CopyFromAnalyzedStatement copyFrom = e.analyze("copy users from ?", new Object[] { files });
assertThat(copyFrom.uri(), isLiteral($(new BytesRef("/f1.json"), new BytesRef("/f2.json")), new ArrayType(DataTypes.STRING)));
}
use of io.crate.types.ArrayType in project crate by crate.
the class SelectStatementAnalyzerTest method testAnyRightLiteral.
@Test
public void testAnyRightLiteral() throws Exception {
SelectAnalyzedStatement stmt = analyze("select id from sys.shards where id = any ([1,2])");
WhereClause whereClause = stmt.relation().querySpec().where();
assertThat(whereClause.hasQuery(), is(true));
assertThat(whereClause.query(), isFunction("any_=", ImmutableList.<DataType>of(DataTypes.INTEGER, new ArrayType(DataTypes.INTEGER))));
}
Aggregations