Search in sources :

Example 1 with SetType

use of io.crate.types.SetType in project crate by crate.

the class LuceneReferenceResolverTest method testGetImplementationWithColumnsOfTypeCollection.

@Test
public void testGetImplementationWithColumnsOfTypeCollection() {
    Reference arrayRef = new Reference(new ReferenceIdent(new TableIdent("s", "t"), "a"), RowGranularity.DOC, DataTypes.DOUBLE_ARRAY);
    assertThat(luceneReferenceResolver.getImplementation(arrayRef), instanceOf(DocCollectorExpression.ChildDocCollectorExpression.class));
    Reference setRef = new Reference(new ReferenceIdent(new TableIdent("s", "t"), "a"), RowGranularity.DOC, new SetType(DataTypes.DOUBLE));
    assertThat(luceneReferenceResolver.getImplementation(setRef), instanceOf(DocCollectorExpression.ChildDocCollectorExpression.class));
}
Also used : SetType(io.crate.types.SetType) Reference(io.crate.metadata.Reference) TableIdent(io.crate.metadata.TableIdent) ReferenceIdent(io.crate.metadata.ReferenceIdent) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 2 with SetType

use of io.crate.types.SetType in project crate by crate.

the class AbstractScalarFunctionsTest method prepareFunctions.

@Before
public void prepareFunctions() throws Exception {
    DocTableInfo tableInfo = TestingTableInfo.builder(new TableIdent(DocSchemaInfo.NAME, "users"), null).add("id", DataTypes.INTEGER).add("name", DataTypes.STRING).add("tags", new ArrayType(DataTypes.STRING)).add("age", DataTypes.INTEGER).add("a", DataTypes.INTEGER).add("x", DataTypes.LONG).add("shape", DataTypes.GEO_SHAPE).add("timestamp", DataTypes.TIMESTAMP).add("timezone", DataTypes.STRING).add("interval", DataTypes.STRING).add("time_format", DataTypes.STRING).add("long_array", new ArrayType(DataTypes.LONG)).add("int_array", new ArrayType(DataTypes.INTEGER)).add("long_set", new SetType(DataTypes.LONG)).add("regex_pattern", DataTypes.STRING).add("geoshape", DataTypes.GEO_SHAPE).add("geopoint", DataTypes.GEO_POINT).add("geostring", DataTypes.STRING).add("is_awesome", DataTypes.BOOLEAN).add("double_val", DataTypes.DOUBLE).add("float_val", DataTypes.DOUBLE).add("short_val", DataTypes.SHORT).add("obj", DataTypes.OBJECT, ImmutableList.of()).build();
    DocTableRelation tableRelation = new DocTableRelation(tableInfo);
    tableSources = ImmutableMap.of(new QualifiedName("users"), tableRelation);
    sqlExpressions = new SqlExpressions(tableSources);
    functions = sqlExpressions.getInstance(Functions.class);
}
Also used : ArrayType(io.crate.types.ArrayType) DocTableInfo(io.crate.metadata.doc.DocTableInfo) SetType(io.crate.types.SetType) QualifiedName(io.crate.sql.tree.QualifiedName) DocTableRelation(io.crate.analyze.relations.DocTableRelation) SqlExpressions(io.crate.testing.SqlExpressions) Before(org.junit.Before)

Example 3 with SetType

use of io.crate.types.SetType in project crate by crate.

the class SubscriptFunctionTest method testNotRegisteredForSets.

@Test
public void testNotRegisteredForSets() throws Exception {
    expectedException.expect(UnsupportedOperationException.class);
    expectedException.expectMessage("unknown function: subscript(integer_set, integer)");
    FunctionIdent functionIdent = new FunctionIdent(SubscriptFunction.NAME, Arrays.<DataType>asList(new SetType(DataTypes.INTEGER), DataTypes.INTEGER));
    functions.getSafe(functionIdent);
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) SetType(io.crate.types.SetType) Test(org.junit.Test)

Example 4 with SetType

use of io.crate.types.SetType in project crate by crate.

the class CollectSetAggregationTest method testReturnType.

@Test
public void testReturnType() throws Exception {
    FunctionIdent fi = new FunctionIdent("collect_set", ImmutableList.<DataType>of(DataTypes.INTEGER));
    assertEquals(new SetType(DataTypes.INTEGER), functions.get(fi).info().returnType());
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) SetType(io.crate.types.SetType) Test(org.junit.Test) AggregationTest(io.crate.operation.aggregation.AggregationTest)

Aggregations

SetType (io.crate.types.SetType)4 Test (org.junit.Test)3 FunctionIdent (io.crate.metadata.FunctionIdent)2 DocTableRelation (io.crate.analyze.relations.DocTableRelation)1 Reference (io.crate.metadata.Reference)1 ReferenceIdent (io.crate.metadata.ReferenceIdent)1 TableIdent (io.crate.metadata.TableIdent)1 DocTableInfo (io.crate.metadata.doc.DocTableInfo)1 AggregationTest (io.crate.operation.aggregation.AggregationTest)1 QualifiedName (io.crate.sql.tree.QualifiedName)1 CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 SqlExpressions (io.crate.testing.SqlExpressions)1 ArrayType (io.crate.types.ArrayType)1 Before (org.junit.Before)1