use of io.crate.types.ArrayType in project crate by crate.
the class PercentileAggregationTest method testReturnTypes.
@Test
public void testReturnTypes() throws Exception {
FunctionIdent synopsis1 = new FunctionIdent(NAME, ImmutableList.<DataType>of(DataTypes.DOUBLE, DataTypes.DOUBLE));
assertEquals(DataTypes.DOUBLE, functions.get(synopsis1).info().returnType());
FunctionIdent synopsis2 = new FunctionIdent(NAME, ImmutableList.<DataType>of(DataTypes.DOUBLE, new ArrayType(DataTypes.DOUBLE)));
assertEquals(new ArrayType(DataTypes.DOUBLE), functions.get(synopsis2).info().returnType());
}
use of io.crate.types.ArrayType in project crate by crate.
the class CompoundLiteralTest method testNestedArrayLiteral.
@Test
public void testNestedArrayLiteral() throws Exception {
Map<String, DataType<?>> expected = Map.of("'string'", DataTypes.STRING, "0", DataTypes.INTEGER, "1.8", DataTypes.DOUBLE, "TRUE", DataTypes.BOOLEAN);
for (Map.Entry<String, DataType<?>> entry : expected.entrySet()) {
Symbol nestedArraySymbol = analyzeExpression("[[" + entry.getKey() + "]]");
assertThat(nestedArraySymbol, Matchers.instanceOf(Literal.class));
Literal<?> nestedArray = (Literal<?>) nestedArraySymbol;
assertThat(nestedArray.valueType(), is(new ArrayType<>(new ArrayType<>(entry.getValue()))));
}
}
use of io.crate.types.ArrayType in project crate by crate.
the class DataTypeAnalyzerTest method testCastToNestedArrayExpressionReturnsArrayType.
@Test
public void testCastToNestedArrayExpressionReturnsArrayType() {
Cast cast = (Cast) SqlParser.createExpression("xs::array(array(int))");
DataType<?> dataType = DataTypeAnalyzer.convert(cast.getType());
assertThat(dataType, is(new ArrayType<>(new ArrayType<>(DataTypes.INTEGER))));
}
use of io.crate.types.ArrayType in project crate by crate.
the class DataTypeTest method testForValueWithEmptyList.
@Test
public void testForValueWithEmptyList() {
List<Object> objects = Arrays.<Object>asList();
DataType type = DataTypes.guessType(objects);
assertEquals(type, new ArrayType(DataTypes.UNDEFINED));
}
use of io.crate.types.ArrayType in project crate by crate.
the class DataTypeTest method testForValueWithTimestampArrayAsString.
@Test
public void testForValueWithTimestampArrayAsString() {
String[] strings = { "2013-09-10T21:51:43", "2013-11-10T21:51:43" };
DataType dataType = DataTypes.guessType(strings);
assertEquals(dataType, new ArrayType(DataTypes.STRING));
}
Aggregations