Package io.crate.types

Examples of io.crate.types.ArrayType


    @Test
    public void testParameterSubcript() throws Exception {
        SelectAnalysis analysis = analyze("select friends[?], counters[?], ['a','b','c'][?] from users",
                new Object[]{"id",2,3});
        assertThat(analysis.outputSymbols().get(0), isReference("friends.id", new ArrayType(DataTypes.LONG)));
        assertThat(analysis.outputSymbols().get(1), isFunction(SubscriptFunction.NAME,
                Arrays.<DataType>asList(new ArrayType(DataTypes.LONG), DataTypes.INTEGER)));
        assertThat(analysis.outputSymbols().get(2), isLiteral("c", DataTypes.STRING));
    }
View Full Code Here


        analysis = analyze("select cast(1+1 as string) from users");
        assertThat(analysis.outputSymbols().get(0), isLiteral("2", DataTypes.STRING));

        analysis = analyze("select cast(friends['id'] as array(string)) from users");
        assertThat(analysis.outputSymbols().get(0), isFunction(ToStringArrayFunction.NAME,
                Arrays.<DataType>asList(new ArrayType(DataTypes.LONG))));
    }
View Full Code Here

        assertThat((String[]) rows[0][0], Matchers.arrayContainingInAnyOrder("foo", "bar"));
    }

    @Test
    public void testEnsureStringTypesAreStringsArrayString() throws Exception {
        DataType[] dataTypes = new DataType[] { new ArrayType(DataTypes.STRING) };
        Object[][] rows = new Object[1][1];
        BytesRef[] refs = new BytesRef[] { new BytesRef("foo"), new BytesRef("bar") };

        rows[0][0] = refs;
        BytesRefUtils.ensureStringTypesAreStrings(dataTypes, rows);
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

                    "date timestamp primary key" +
                ") partitioned by (date)");

        assertThat(md.columns().size(), is(4));
        assertThat(md.primaryKey(), Matchers.contains(new ColumnIdent("id"), new ColumnIdent("date")));
        assertTrue(md.references().get(new ColumnIdent("tags")).type().equals(new ArrayType(DataTypes.STRING)));
    }
View Full Code Here

                "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

        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

TOP

Related Classes of io.crate.types.ArrayType

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.