use of io.crate.types.DataType 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.DataType in project crate by crate.
the class SelectStatementAnalyzerTest method testCastExpression.
@Test
public void testCastExpression() throws Exception {
SelectAnalyzedStatement analysis = analyze("select cast(other_id as string) from users");
assertThat(analysis.relation().querySpec().outputs().get(0), isFunction(CastFunctionResolver.FunctionNames.TO_STRING, Arrays.<DataType>asList(DataTypes.LONG)));
analysis = analyze("select cast(1+1 as string) from users");
assertThat(analysis.relation().querySpec().outputs().get(0), isLiteral("2", DataTypes.STRING));
analysis = analyze("select cast(friends['id'] as array(string)) from users");
assertThat(analysis.relation().querySpec().outputs().get(0), isFunction(CastFunctionResolver.FunctionNames.TO_STRING_ARRAY, Arrays.<DataType>asList(new ArrayType(DataTypes.LONG))));
}
use of io.crate.types.DataType 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))));
}
use of io.crate.types.DataType in project crate by crate.
the class UpdateAnalyzerTest method testUpdateDynamicNestedArrayParam.
@Test
public void testUpdateDynamicNestedArrayParam() throws Exception {
UpdateAnalyzedStatement statement = analyze("update users set new=? where id=1", new Object[] { new Object[] { new Object[] { 1.9, 4.8 }, new Object[] { 9.7, 12.7 } } });
DataType dataType = statement.nestedStatements().get(0).assignments().values().iterator().next().valueType();
assertThat(dataType, is((DataType) new ArrayType(new ArrayType(DoubleType.INSTANCE))));
}
use of io.crate.types.DataType in project crate by crate.
the class UpdateAnalyzerTest method testUpdateDynamicNestedArrayParamLiteral.
@Test
public void testUpdateDynamicNestedArrayParamLiteral() throws Exception {
UpdateAnalyzedStatement statement = analyze("update users set new=[[1.9, 4.8], [9.7, 12.7]]");
DataType dataType = statement.nestedStatements().get(0).assignments().values().iterator().next().valueType();
assertThat(dataType, is((DataType) new ArrayType(new ArrayType(DoubleType.INSTANCE))));
}
Aggregations