Search in sources :

Example 1 with BatchedQueryResult

use of io.confluent.ksql.api.client.BatchedQueryResult in project ksql by confluentinc.

the class ClientImpl method executeQuery.

@Override
public BatchedQueryResult executeQuery(final String sql, final Map<String, Object> properties) {
    if (clientOptions.getConsistencyLevel() == ConsistencyLevel.MONOTONIC_SESSION) {
        requestProperties.put(KsqlRequestConfig.KSQL_REQUEST_QUERY_PULL_CONSISTENCY_OFFSET_VECTOR, serializedConsistencyVector.get());
    }
    final BatchedQueryResult result = new BatchedQueryResultImpl();
    makeQueryRequest(sql, properties, result, (context, recordParser, cf, request) -> new ExecuteQueryResponseHandler(context, recordParser, cf, clientOptions.getExecuteQueryMaxResultRows(), serializedConsistencyVector));
    return result;
}
Also used : BatchedQueryResult(io.confluent.ksql.api.client.BatchedQueryResult)

Example 2 with BatchedQueryResult

use of io.confluent.ksql.api.client.BatchedQueryResult in project ksql by confluentinc.

the class ClientIntegrationTest method shouldExecutePushWithLimitQuery.

@Test
public void shouldExecutePushWithLimitQuery() throws Exception {
    // When
    final BatchedQueryResult batchedQueryResult = client.executeQuery(PUSH_QUERY_WITH_LIMIT);
    // Then
    assertThat(batchedQueryResult.queryID().get(), is(notNullValue()));
    verifyStreamRows(batchedQueryResult.get(), PUSH_QUERY_LIMIT_NUM_ROWS);
}
Also used : BatchedQueryResult(io.confluent.ksql.api.client.BatchedQueryResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 3 with BatchedQueryResult

use of io.confluent.ksql.api.client.BatchedQueryResult in project ksql by confluentinc.

the class ClientIntegrationTest method shouldExecutePullQuery.

@Test
public void shouldExecutePullQuery() throws Exception {
    // When
    final BatchedQueryResult batchedQueryResult = client.executeQuery(PULL_QUERY_ON_TABLE);
    // Then
    assertThat(batchedQueryResult.queryID().get(), is(notNullValue()));
    verifyPullQueryRows(batchedQueryResult.get());
}
Also used : BatchedQueryResult(io.confluent.ksql.api.client.BatchedQueryResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 4 with BatchedQueryResult

use of io.confluent.ksql.api.client.BatchedQueryResult in project ksql by confluentinc.

the class ClientIntegrationTest method shouldTerminatePushQueryIssuedViaExecuteQuery.

@Test
public void shouldTerminatePushQueryIssuedViaExecuteQuery() throws Exception {
    // Given: one persistent query for the agg table
    verifyNumActiveQueries(1);
    // Issue non-terminating push query via executeQuery(). This is NOT an expected use case
    final BatchedQueryResult batchedQueryResult = client.executeQuery(PUSH_QUERY);
    final String queryId = batchedQueryResult.queryID().get();
    assertThat(queryId, is(notNullValue()));
    // Query is running on server, and StreamedQueryResult is not complete
    verifyNumActiveQueries(2);
    assertThat(batchedQueryResult.isDone(), is(false));
    // When
    client.terminatePushQuery(queryId).get();
    // Then: query is no longer running on server, and BatchedQueryResult is complete
    verifyNumActiveQueries(1);
    assertThatEventually(batchedQueryResult::isDone, is(true));
    assertThat(batchedQueryResult.isCompletedExceptionally(), is(false));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) BatchedQueryResult(io.confluent.ksql.api.client.BatchedQueryResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 5 with BatchedQueryResult

use of io.confluent.ksql.api.client.BatchedQueryResult in project ksql by confluentinc.

the class ConsistencyOffsetVectorFunctionalTest method shouldNotRoundTripCVWhenExecutePullQuery.

@Test
public void shouldNotRoundTripCVWhenExecutePullQuery() throws Exception {
    // When
    final BatchedQueryResult batchedQueryResult = eventualClient.executeQuery(PULL_QUERY_ON_TABLE);
    batchedQueryResult.get();
    // Then
    assertThat(batchedQueryResult.queryID().get(), is(notNullValue()));
    assertThat(((ClientImpl) eventualClient).getSerializedConsistencyVector(), is(isEmptyString()));
}
Also used : BatchedQueryResult(io.confluent.ksql.api.client.BatchedQueryResult) Test(org.junit.Test)

Aggregations

BatchedQueryResult (io.confluent.ksql.api.client.BatchedQueryResult)16 Test (org.junit.Test)9 Row (io.confluent.ksql.api.client.Row)8 IntegrationTest (io.confluent.common.utils.IntegrationTest)7 ExecutionException (java.util.concurrent.ExecutionException)5 MigrationException (io.confluent.ksql.tools.migrations.MigrationException)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 KsqlArray (io.confluent.ksql.api.client.KsqlArray)2 KsqlObject (io.confluent.ksql.api.client.KsqlObject)2 KsqlClientException (io.confluent.ksql.api.client.exception.KsqlClientException)2 List (java.util.List)2 ZooKeeperClientException (kafka.zookeeper.ZooKeeperClientException)2 ImmutableList (com.google.common.collect.ImmutableList)1 Client (io.confluent.ksql.api.client.Client)1 ServerInfo (io.confluent.ksql.api.client.ServerInfo)1 ClientImpl (io.confluent.ksql.api.client.impl.ClientImpl)1 ConnectorList (io.confluent.ksql.rest.entity.ConnectorList)1 StreamedRow (io.confluent.ksql.rest.entity.StreamedRow)1 MigrationConfig (io.confluent.ksql.tools.migrations.MigrationConfig)1 ServerVersionUtil.getServerInfo (io.confluent.ksql.tools.migrations.util.ServerVersionUtil.getServerInfo)1