@Test
public void testInformationSchemaTables() throws Exception {
Routing routing = new Routing(MapBuilder.<String, Map<String, Set<Integer>>>newMapBuilder().put(
null, MapBuilder.<String, Set<Integer>>newMapBuilder().put("information_schema.tables", null).map()
).map());
CollectNode collectNode = new CollectNode("tablesCollect", routing);
InformationSchemaInfo schemaInfo = cluster().getInstance(InformationSchemaInfo.class);
TableInfo tablesTableInfo = schemaInfo.getTableInfo("tables");
List<Symbol> toCollect = new ArrayList<>();
for (ReferenceInfo info : tablesTableInfo.columns()) {
toCollect.add(new Reference(info));
}
Symbol tableNameRef = toCollect.get(1);
FunctionImplementation eqImpl = functions.get(new FunctionIdent(EqOperator.NAME,
ImmutableList.<DataType>of(DataTypes.STRING, DataTypes.STRING)));
Function whereClause = new Function(eqImpl.info(),
Arrays.asList(tableNameRef, Literal.newLiteral("shards")));
collectNode.whereClause(new WhereClause(whereClause));
collectNode.toCollect(toCollect);
collectNode.maxRowGranularity(RowGranularity.DOC);
Object[][] result = operation.collect(collectNode).get();
System.out.println(TestingHelpers.printedTable(result));
assertEquals("sys| shards| 1| 0| NULL| NULL| NULL\n", TestingHelpers.printedTable(result));
}