Search in sources :

Example 61 with DrillClient

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;
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) DrillClient(org.apache.drill.exec.client.DrillClient) RecordBatchDef(org.apache.drill.exec.proto.UserBitShared.RecordBatchDef) Test(org.junit.Test)

Aggregations

DrillClient (org.apache.drill.exec.client.DrillClient)61 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)57 Drillbit (org.apache.drill.exec.server.Drillbit)55 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)55 Test (org.junit.Test)53 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)37 ValueVector (org.apache.drill.exec.vector.ValueVector)28 VectorWrapper (org.apache.drill.exec.record.VectorWrapper)13 ExecTest (org.apache.drill.exec.ExecTest)8 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)6 DrillConfig (org.apache.drill.common.config.DrillConfig)4 VarBinaryHolder (org.apache.drill.exec.expr.holders.VarBinaryHolder)3 QueryData (org.apache.drill.exec.proto.UserBitShared.QueryData)3 VarBinaryVector (org.apache.drill.exec.vector.VarBinaryVector)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)2 BigIntVector (org.apache.drill.exec.vector.BigIntVector)2 Ignore (org.junit.Ignore)2 Stopwatch (com.google.common.base.Stopwatch)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1