Search in sources :

Example 1 with QueryClient

use of io.cdap.cdap.client.QueryClient in project cdap by caskdata.

the class CLIMainLinkTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    cliConfig = createCLIConfigWithURIPrefix(STANDALONE.getBaseURI());
    LaunchOptions launchOptions = new LaunchOptions("", true, true, false, null, LaunchOptions.DEFAULT.getUri());
    cliMain = new CLIMain(launchOptions, cliConfig);
    programClient = new ProgramClient(cliConfig.getClientConfig());
    queryClient = new QueryClient(cliConfig.getClientConfig());
    cli = cliMain.getCLI();
    testSetup(cli, STANDALONE, TMP_FOLDER);
}
Also used : ProgramClient(io.cdap.cdap.client.ProgramClient) QueryClient(io.cdap.cdap.client.QueryClient) BeforeClass(org.junit.BeforeClass)

Example 2 with QueryClient

use of io.cdap.cdap.client.QueryClient in project cdap by caskdata.

the class CLIMainTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    cliConfig = createCLIConfig(STANDALONE.getBaseURI());
    LaunchOptions launchOptions = new LaunchOptions(LaunchOptions.DEFAULT.getUri(), true, true, false);
    cliMain = new CLIMain(launchOptions, cliConfig);
    programClient = new ProgramClient(cliConfig.getClientConfig());
    queryClient = new QueryClient(cliConfig.getClientConfig());
    cli = cliMain.getCLI();
    testSetup(cli, STANDALONE, TMP_FOLDER);
}
Also used : ProgramClient(io.cdap.cdap.client.ProgramClient) QueryClient(io.cdap.cdap.client.QueryClient) BeforeClass(org.junit.BeforeClass)

Example 3 with QueryClient

use of io.cdap.cdap.client.QueryClient in project cdap by caskdata.

the class CLITestBase method dropHiveDb.

private void dropHiveDb(String hiveDb) throws Exception {
    QueryClient queryClient = getQueryClient();
    assertExploreQuerySuccess(queryClient.execute(NamespaceId.DEFAULT, "drop database " + hiveDb));
}
Also used : QueryClient(io.cdap.cdap.client.QueryClient)

Example 4 with QueryClient

use of io.cdap.cdap.client.QueryClient in project cdap by caskdata.

the class GenerateClientUsageExample method queryClient.

public void queryClient() throws Exception {
    // Construct the client used to interact with CDAP
    QueryClient queryClient = new QueryClient(clientConfig);
    // Perform an ad-hoc query using the Purchase example
    ListenableFuture<ExploreExecutionResult> resultFuture = queryClient.execute(NamespaceId.DEFAULT, "SELECT * FROM dataset_history WHERE customer IN ('Alice','Bob')");
    ExploreExecutionResult results = resultFuture.get();
    // Fetch schema
    List<ColumnDesc> schema = results.getResultSchema();
    String[] header = new String[schema.size()];
    for (int i = 0; i < header.length; i++) {
        ColumnDesc column = schema.get(i);
        // Hive columns start at 1
        int index = column.getPosition() - 1;
        header[index] = column.getName() + ": " + column.getType();
    }
}
Also used : ColumnDesc(io.cdap.cdap.proto.ColumnDesc) ExploreExecutionResult(io.cdap.cdap.explore.client.ExploreExecutionResult) QueryClient(io.cdap.cdap.client.QueryClient)

Example 5 with QueryClient

use of io.cdap.cdap.client.QueryClient in project cdap by caskdata.

the class CLITestBase method createHiveDB.

private void createHiveDB(String hiveDb) throws Exception {
    QueryClient queryClient = getQueryClient();
    ListenableFuture<ExploreExecutionResult> future = queryClient.execute(NamespaceId.DEFAULT, "create database " + hiveDb);
    assertExploreQuerySuccess(future);
    future = queryClient.execute(NamespaceId.DEFAULT, "describe database " + hiveDb);
    assertExploreQuerySuccess(future);
}
Also used : ExploreExecutionResult(io.cdap.cdap.explore.client.ExploreExecutionResult) QueryClient(io.cdap.cdap.client.QueryClient)

Aggregations

QueryClient (io.cdap.cdap.client.QueryClient)5 ProgramClient (io.cdap.cdap.client.ProgramClient)2 ExploreExecutionResult (io.cdap.cdap.explore.client.ExploreExecutionResult)2 BeforeClass (org.junit.BeforeClass)2 ColumnDesc (io.cdap.cdap.proto.ColumnDesc)1