Package io.crate.metadata

Examples of io.crate.metadata.ColumnIdent


        // FYI: insert nested clustered by test here too
        InsertFromValuesAnalysis analysis = (InsertFromValuesAnalysis)analyze("insert into nested_pk (id, o) values (?, ?)",
                new Object[]{1, new MapBuilder<String, Object>().put("b", 4).map()});
        assertThat(analysis.ids().size(), is(1));
        assertThat(analysis.ids().get(0),
                is(new Id(Arrays.asList(new ColumnIdent("id"), new ColumnIdent("o.b")), Arrays.asList(new BytesRef("1"), new BytesRef("4")), new ColumnIdent("o.b")).stringValue()));
    }
View Full Code Here


    public void testNestedPkAllColumns() throws Exception {
        InsertFromValuesAnalysis analysis = (InsertFromValuesAnalysis)analyze("insert into nested_pk values (?, ?)",
                new Object[]{1, new MapBuilder<String, Object>().put("b", 4).map()});
        assertThat(analysis.ids().size(), is(1));
        assertThat(analysis.ids().get(0),
                is(new Id(Arrays.asList(new ColumnIdent("id"), new ColumnIdent("o.b")), Arrays.asList(new BytesRef("1"), new BytesRef("4")), new ColumnIdent("o.b")).stringValue()));
    }
View Full Code Here

    @Test
    public void testTwistedNestedPk() throws Exception {
        InsertFromValuesAnalysis analysis = (InsertFromValuesAnalysis) analyze("insert into nested_pk (o, id) values (?, ?)",
                new Object[]{new MapBuilder<String, Object>().put("b", 4).map(), 1});
        assertThat(analysis.ids().get(0),
                is(new Id(Arrays.asList(new ColumnIdent("id"), new ColumnIdent("o.b")), Arrays.asList(new BytesRef("1"), new BytesRef("4")), new ColumnIdent("o.b")).stringValue()));

    }
View Full Code Here

        for (int i = 0; i < ROWS; i++) {
            Object[] object = getRandomObject();
            bulkArgs[i= object;

            String id = (String)object[0];
            Id esId = new Id(ImmutableList.of(new ColumnIdent("id")), ImmutableList.of(new BytesRef(id)), new ColumnIdent("id"), true);
            ids.put(id, esId.stringValue());
        }
        SQLBulkRequest request = new SQLBulkRequest(SINGLE_INSERT_SQL_STMT, bulkArgs);
        client().execute(SQLBulkAction.INSTANCE, request).actionGet();
        refresh(client());
View Full Code Here

            } else {
                additionalPkColumn = column;
            }
        }
        assertNotNull(idColumn);
        assertThat(idColumn.ident(), equalTo(new ColumnIdent("id")));
        assertThat(idColumn.dataType(), equalTo("long"));

        assertNotNull(additionalPkColumn);
        assertThat(additionalPkColumn.ident(), equalTo(new ColumnIdent("additional_pk")));
        assertThat(additionalPkColumn.dataType(), equalTo("string"));
    }
View Full Code Here

        AddColumnAnalysis analysis = (AddColumnAnalysis) analyze(
                "alter table users add column foo['x']['y'] string");

        assertThat(analysis.analyzedTableElements().columns().size(), is(2)); // id pk column is also added
        AnalyzedColumnDefinition column = analysis.analyzedTableElements().columns().get(0);
        assertThat(column.ident(), Matchers.equalTo(new ColumnIdent("foo")));
        assertThat(column.children().size(), is(1));
        AnalyzedColumnDefinition xColumn = column.children().get(0);
        assertThat(xColumn.ident(), Matchers.equalTo(new ColumnIdent("foo", Arrays.asList("x"))));
        assertThat(xColumn.children().size(), is(1));
        AnalyzedColumnDefinition yColumn = xColumn.children().get(0);
        assertThat(yColumn.ident(), Matchers.equalTo(new ColumnIdent("foo", Arrays.asList("x", "y"))));
        assertThat(yColumn.children().size(), is(0));

        Map<String, Object> mapping = analysis.analyzedTableElements().toMapping();
        Map foo = (Map) StringObjectMaps.getByPath(mapping, "properties.foo");
        assertThat((String)foo.get("type"), is("object"));
View Full Code Here

                cluster().getInstance(TransportCreateIndexAction.class),
                "bulk_import",
                Arrays.asList(ID_IDENT),
                Arrays.<Input<?>>asList(idInput),
                ImmutableList.<Input<?>>of(),
                new ColumnIdent("id"),
                idInput,
                sourceInput,
                collectExpressions,
                20,
                null, null,
View Full Code Here

    @Test
    public void testToNestedStringObjectMap() throws Exception {

        Map<ColumnIdent, Object> columnIdentMap = new HashMap<>();
        columnIdentMap.put(new ColumnIdent("some", Arrays.asList("nested", "column")), "foo");
        Map<String, Object> convertedMap = TestableWriterProjector.toNestedStringObjectMap(columnIdentMap);

        Map someMap = (Map) convertedMap.get("some");
        Map nestedMap = (Map) someMap.get("nested");
        assertThat((String)nestedMap.get("column"), is("foo"));
View Full Code Here

                mock(TransportCreateIndexAction.class),
                "bulk_import",
                Arrays.asList(ID_IDENT),
                Arrays.<Input<?>>asList(idInput),
                ImmutableList.<Input<?>>of(),
                new ColumnIdent("y"),
                routingInput,
                sourceInput,
                collectExpressions,
                20,
                null, null,
View Full Code Here

        UpdateAnalysis.NestedAnalysis analysis =
                analyze("update users set name=?, other_id=?, friends=? where id=?",
                        new Object[]{"Jeltz", 0, friends, "9"});
        assertThat(analysis.assignments().size(), is(3));
        assertLiteralSymbol(
                analysis.assignments().get(new Reference(userTableInfo.getReferenceInfo(new ColumnIdent("name")))),
                "Jeltz"
        );
        assertLiteralSymbol(
                analysis.assignments().get(new Reference(userTableInfo.getReferenceInfo(new ColumnIdent("friends")))),
                friends,
                new ArrayType(DataTypes.OBJECT)
        );
        assertLiteralSymbol(
                analysis.assignments().get(new Reference(userTableInfo.getReferenceInfo(new ColumnIdent("other_id")))),
                0L
        );

        assertLiteralSymbol(((Function)analysis.whereClause().query()).arguments().get(1), 9L);
    }
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.