use of io.crate.metadata.information.InformationSchemaInfo in project crate by crate.
the class HandlerSideLevelCollectTest method testInformationSchemaColumns.
@Test
public void testInformationSchemaColumns() throws Exception {
InformationSchemaInfo schemaInfo = internalCluster().getInstance(InformationSchemaInfo.class);
TableInfo tableInfo = schemaInfo.getTableInfo("columns");
assert tableInfo != null;
Routing routing = tableInfo.getRouting(WhereClause.MATCH_ALL, null);
List<Symbol> toCollect = new ArrayList<>();
for (Reference ref : tableInfo.columns()) {
toCollect.add(ref);
}
RoutedCollectPhase collectNode = collectNode(routing, toCollect, RowGranularity.DOC);
Bucket result = collect(collectNode);
String expected = "id| string| NULL| false| true| 1| cluster| sys\n" + "master_node| string| NULL| false| true| 2| cluster| sys\n" + "name| string| NULL| false| true| 3| cluster| sys\n" + "settings| object| NULL| false| true| 4| cluster| sys\n";
assertThat(TestingHelpers.printedTable(result), Matchers.containsString(expected));
// second time - to check if the internal iterator resets
result = collect(collectNode);
assertThat(TestingHelpers.printedTable(result), Matchers.containsString(expected));
}
use of io.crate.metadata.information.InformationSchemaInfo in project crate by crate.
the class HandlerSideLevelCollectTest method testInformationSchemaTables.
@Test
public void testInformationSchemaTables() throws Exception {
InformationSchemaInfo schemaInfo = internalCluster().getInstance(InformationSchemaInfo.class);
TableInfo tablesTableInfo = schemaInfo.getTableInfo("tables");
Routing routing = tablesTableInfo.getRouting(WhereClause.MATCH_ALL, null);
List<Symbol> toCollect = new ArrayList<>();
for (Reference reference : tablesTableInfo.columns()) {
toCollect.add(reference);
}
Symbol tableNameRef = toCollect.get(8);
FunctionImplementation eqImpl = functions.get(new FunctionIdent(EqOperator.NAME, ImmutableList.of(DataTypes.STRING, DataTypes.STRING)));
Function whereClause = new Function(eqImpl.info(), Arrays.asList(tableNameRef, Literal.of("shards")));
RoutedCollectPhase collectNode = collectNode(routing, toCollect, RowGranularity.DOC, new WhereClause(whereClause));
Bucket result = collect(collectNode);
assertThat(TestingHelpers.printedTable(result), is("NULL| NULL| strict| 0| 1| NULL| NULL| NULL| shards| sys| NULL\n"));
}
Aggregations