Package io.crate.metadata

Examples of io.crate.metadata.ColumnIdent


    public void testUpdateWithEmptyObjectArray() throws Exception {
        UpdateAnalysis.NestedAnalysis analysis = analyze("update users set friends=? where other_id=0",
                new Object[]{ new Map[0], 0 });

        Literal friendsLiteral = (Literal)analysis.assignments().get(
                new Reference(userTableInfo.getReferenceInfo(new ColumnIdent("friends"))));
        assertThat(friendsLiteral.valueType().id(), is(ArrayType.ID));
        assertEquals(DataTypes.OBJECT, ((ArrayType)friendsLiteral.valueType()).innerType());
        assertThat(((Object[])friendsLiteral.value()).length, is(0));
    }
View Full Code Here


public class ESFieldExtractorTest {

    @Test
    public void testPath2() throws Exception {

        ESFieldExtractor.Source ex = new ESFieldExtractor.Source(new ColumnIdent("top", "child1"));
        Map<String, Object> source;

        source = ImmutableMap.of();
        assertNull(ex.toValue(source));
View Full Code Here

    }

    @Test
    public void testPath3() throws Exception {
        ColumnIdent ci = new ColumnIdent("a", ImmutableList.of("b", "c"));
        ESFieldExtractor.Source ex = new ESFieldExtractor.Source(ci);
        Map<String, Object> source;

        source = ImmutableMap.<String, Object>of(
                "a", ImmutableMap.of("b", ImmutableMap.of("c", 1)
View Full Code Here

        assertEquals(1, ex.toValue(source));
    }

    @Test
    public void testNullInList() throws Exception {
        ESFieldExtractor.Source ex = new ESFieldExtractor.Source(new ColumnIdent("top", "child1"));
        // test null value in list
        HashMap<String, Object> nullMap = new HashMap<String, Object>(1);
        nullMap.put("child1", null);
        ImmutableMap<String, Object> source = ImmutableMap.<String, Object>of(
                "top", ImmutableList.of(
View Full Code Here

        LineContext context = new LineContext(new CollectorContext());

        String source = "{\"name\": \"foo\", \"details\": {\"age\": 43}}";
        context.rawSource(source.getBytes());

        assertNull(context.get(new ColumnIdent("invalid", "column")));
        assertNull(context.get(new ColumnIdent("details", "invalid")));
        assertEquals(43, context.get(new ColumnIdent("details", "age")));
    }
View Full Code Here

        Preconditions.checkArgument(!name.startsWith("_"), "Column ident must not start with '_'");
        this.name = name;
        if (this.parent != null) {
            this.ident = ColumnIdent.getChild(this.parent.ident, name);
        } else {
            this.ident = new ColumnIdent(name);
        }
    }
View Full Code Here

        return null;
    }

    @Override
    public Symbol visitReference(Reference reference, Context context) {
        ColumnIdent columnIdent = reference.info().ident().columnIdent();
        if (!reference.info().ident().tableIdent().equals(context.table.ident())) {
            invalidate(context);
            return reference;
        }

        // where booleanCol; can be handled like: where booleanCol = true;
        if (reference.valueType().equals(DataTypes.BOOLEAN)) {
            if (columnIdent.equals(context.table.clusteredBy())) {
                setClusterBy(context, Literal.newLiteral(true));
            }
            int idx = context.table.primaryKey().indexOf(columnIdent);
            if (idx >= 0) {
                setPrimaryKey(context, Literal.newLiteral(true), idx);
View Full Code Here

            invalidate(context);
            return function;
        }

        Reference reference = (Reference) left;
        ColumnIdent columnIdent = reference.info().ident().columnIdent();
        if (!reference.info().ident().tableIdent().equals(context.table.ident())) {
            invalidate(context);
            return function;
        }

        boolean clusteredBySet = false;
        if (functionName.equals(EqOperator.NAME)) {
            if (columnIdent.equals(context.table.clusteredBy())) {
                setClusterBy(context, (Literal) right);
                clusteredBySet = true;
            }
            if (columnIdent.name().equals("_version")) {
                setVersion(context, right);
                return function;
            }
        }
View Full Code Here

    @Override
    public DynamicReference getDynamic(ColumnIdent ident, boolean forWrite) {
        boolean parentIsIgnored = false;
        if (!ident.isColumn()) {
            // see if parent is strict object
            ColumnIdent parentIdent = ident.getParent();
            ReferenceInfo parentInfo = null;

            while (parentIdent != null) {
                parentInfo = getReferenceInfo(parentIdent);
                if (parentInfo != null) {
                    break;
                }
                parentIdent = parentIdent.getParent();
            }

            if (parentInfo != null) {
                switch (parentInfo.columnPolicy()) {
                    case STRICT:
View Full Code Here

        }
    }

    private void validateIndexDefinitions() {
        for (Map.Entry<String, Set<String>> entry : copyToMap.entrySet()) {
            ColumnIdent columnIdent = ColumnIdent.fromPath(entry.getKey());
            if (!columnIdents.contains(columnIdent)) {
                throw new ColumnUnknownException(columnIdent.sqlFqn());
            }
            if (!columnTypes.get(columnIdent).equalsIgnoreCase("string")) {
                throw new IllegalArgumentException("INDEX definition only support 'string' typed source columns");
            }
        }
View Full Code Here

TOP

Related Classes of io.crate.metadata.ColumnIdent

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.