use of org.ojai.Document in project drill by apache.
the class TestSimpleJson method testPushdownStringEqual.
@Test
public void testPushdownStringEqual() throws Exception {
setColumnWidths(new int[] { 25, 40, 40, 40 });
final String sql = "SELECT\n" + " _id, name, business.hours.Monday.`open`, categories[1], years[2], full_address\n" + "FROM\n" + " hbase.`business` business\n" + "WHERE\n" + " name = 'Sprint'";
final Document queryResult = MapRDB.newDocument();
SingleRowListener listener = new SingleRowListener() {
@Override
protected void rowArrived(QueryDataBatch result) {
try {
final RecordBatchLoader loader = new RecordBatchLoader(getAllocator());
loader.load(result.getHeader().getDef(), result.getData());
StringBuilder sb = new StringBuilder();
VectorUtil.appendVectorAccessibleContent(loader, sb, "|", false);
loader.clear();
queryResult.set("result", sb.toString());
} catch (SchemaChangeException e) {
queryResult.set("error", "true");
}
}
};
testWithListener(QueryType.SQL, sql, listener);
listener.waitForCompletion();
assertNull(queryResult.getString("error"));
assertNotNull(queryResult.getString("result"));
String[] fields = queryResult.getString("result").split("\\|");
assertEquals("1970-01-01T11:00:00.000", fields[2]);
assertEquals("Mobile Phones", fields[3]);
assertEquals("2016.0", fields[4]);
final String[] expectedPlan = { "condition=\\(name = \"Sprint\"\\)" };
final String[] excludedPlan = {};
PlanTestBase.testPlanMatchingPatterns(sql, expectedPlan, excludedPlan);
}
Aggregations