Package io.crate.types

Examples of io.crate.types.DataType


    }


    @Test
    public void testWhereRefInSetLiteralIsConvertedToBooleanQuery() throws Exception {
        DataType dataType = new SetType(DataTypes.STRING);
        Reference foo = createReference("foo", DataTypes.STRING);
        WhereClause whereClause = new WhereClause(
                createFunction(InOperator.NAME, DataTypes.BOOLEAN,
                        foo,
                        Literal.newLiteral(dataType, Sets.newHashSet(new BytesRef("foo"), new BytesRef("bar")))
View Full Code Here


                        return false;
                    }

                    List<DataType> types = ((Function) item).info().ident().argumentTypes();
                    for (int i = 0, typesSize = types.size(); i < typesSize; i++) {
                        DataType type = types.get(i);
                        DataType expected = argumentTypes.get(i);
                        if (!expected.equals(type)) {
                            mismatchDescription.appendText("argument ").appendValue(i + 1).appendText(" has wrong type ").appendValue(type.toString());
                            return false;
                        }
                    }
                }
View Full Code Here

    @Test
    public void testEquals() throws Exception {
        TableIdent tableIdent = new TableIdent("doc", "test");
        ReferenceIdent referenceIdent = new ReferenceIdent(tableIdent, "object_column");
        DataType dataType1 = new ArrayType(DataTypes.OBJECT);
        DataType dataType2 = new ArrayType(DataTypes.OBJECT);
        ReferenceInfo referenceInfo1 = new ReferenceInfo(referenceIdent, RowGranularity.DOC, dataType1);
        ReferenceInfo referenceInfo2 = new ReferenceInfo(referenceIdent, RowGranularity.DOC, dataType2);
        assertTrue(referenceInfo1.equals(referenceInfo2));
    }
View Full Code Here

        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")).type();
        assertThat(type, Matchers.<DataType>equalTo(new ArrayType(DataTypes.STRING)));
    }
View Full Code Here

        return new FunctionInfo(new FunctionIdent(functionName, dataTypes), DataTypes.LONG);
    }

    protected static void validateTypes(List<DataType> dataTypes) {
        Preconditions.checkArgument(dataTypes.size() == 2);
        DataType leftType = dataTypes.get(0);
        DataType rightType = dataTypes.get(1);
        Preconditions.checkArgument(ALLOWED_TYPES.contains(leftType),
                "invalid type %s of left argument", leftType.toString());
        Preconditions.checkArgument(ALLOWED_TYPES.contains(rightType),
                "invalid type %s of right argument", leftType.toString());
    }
View Full Code Here

        assertThat(actual, is(expected));
    }

    @Test
    public void testNormalizeWithReference() throws Exception {
        final DataType arrayType = new ArrayType(DataTypes.STRING);
        ToIntArrayFunction impl = (ToIntArrayFunction)functions.get(
                new FunctionIdent(ToIntArrayFunction.NAME, ImmutableList.of(arrayType)));

        Reference foo = TestingHelpers.createReference("foo", arrayType);
        Symbol symbol = impl.normalizeSymbol(new Function(impl.info(), Arrays.<Symbol>asList(foo)));
View Full Code Here

        assertThat(eval(null, DataTypes.LONG), Matchers.nullValue());
        assertThat(eval(null, DataTypes.STRING), Matchers.nullValue());
    }

    private Object[] eval(final Object objects, DataType innerType) {
        final DataType arrayType = new ArrayType(innerType);
        ToIntArrayFunction impl = (ToIntArrayFunction)functions.get(
                new FunctionIdent(ToIntArrayFunction.NAME, ImmutableList.of(arrayType)));

        Literal input = new Literal() {
            @Override
View Full Code Here

        assertThat(actual, is(expected));
    }


    private Object[] eval(final Object objects, DataType innerType) {
        final DataType arrayType = new ArrayType(innerType);
        ToFloatArrayFunction impl = (ToFloatArrayFunction)functions.get(
                new FunctionIdent(ToFloatArrayFunction.NAME, ImmutableList.of(arrayType)));

        Literal input = new Literal() {
            @Override
View Full Code Here

        assertThat(actual, is(expected));
    }


    private Object[] eval(final Object objects, DataType innerType) {
        final DataType arrayType = new ArrayType(innerType);
        ToShortArrayFunction impl = (ToShortArrayFunction)functions.get(
                new FunctionIdent(ToShortArrayFunction.NAME, ImmutableList.of(arrayType)));

        Literal input = new Literal() {
            @Override
View Full Code Here

        functions.get(new FunctionIdent(ToBooleanArrayFunction.NAME, ImmutableList.<DataType>of(DataTypes.OBJECT)));
    }


    private Object[] eval(final Object objects, DataType innerType) {
        final DataType arrayType = new ArrayType(innerType);
        ToBooleanArrayFunction impl = (ToBooleanArrayFunction)functions.get(
                new FunctionIdent(ToBooleanArrayFunction.NAME, ImmutableList.of(arrayType)));

        Literal input = new Literal() {
            @Override
View Full Code Here

TOP

Related Classes of io.crate.types.DataType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.