use of org.apache.drill.exec.client.DrillClient in project drill by apache.
the class TestComplexToJson method test.
@Test
public void test() throws Exception {
DrillClient parent_client = client;
List<QueryDataBatch> results;
RecordBatchLoader loader = new RecordBatchLoader(getAllocator());
client = new DrillClient(config, serviceSet.getCoordinator());
client.setSupportComplexTypes(false);
client.connect();
results = testSqlWithResults("select * from dfs_test.`[WORKING_PATH]/src/test/resources/store/text/data/regions.csv`");
loader.load(results.get(0).getHeader().getDef(), results.get(0).getData());
RecordBatchDef def = results.get(0).getHeader().getDef();
// the entire row is returned as a single column
assertEquals(1, def.getFieldCount());
// with setSupportComplexTypes == false, the column mode should be REQUIRED
assertTrue(def.getField(0).getMajorType().getMode() == DataMode.REQUIRED);
loader.clear();
for (QueryDataBatch result : results) {
result.release();
}
client.close();
client = new DrillClient(config, serviceSet.getCoordinator());
client.setSupportComplexTypes(true);
client.connect();
results = testSqlWithResults("select * from dfs_test.`[WORKING_PATH]/src/test/resources/store/text/data/regions.csv`");
loader.load(results.get(0).getHeader().getDef(), results.get(0).getData());
def = results.get(0).getHeader().getDef();
// the entire row is returned as a single column
assertEquals(1, def.getFieldCount());
// with setSupportComplexTypes == true, the column mode should be REPEATED
assertTrue(def.getField(0).getMajorType().getMode() == DataMode.REPEATED);
loader.clear();
for (QueryDataBatch result : results) {
result.release();
}
client.close();
client = parent_client;
}
Aggregations