Search in sources :

Example 26 with Row

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

the class ConsistencyOffsetVectorFunctionalTest method shouldRoundTripCVWhenExecutePullQuery.

@Test
public void shouldRoundTripCVWhenExecutePullQuery() throws Exception {
    // When
    final BatchedQueryResult batchedQueryResult = consistencClient.executeQuery(PULL_QUERY_ON_TABLE);
    final List<Row> rows = batchedQueryResult.get();
    // Then
    assertThat(rows, hasSize(1));
    assertThat(batchedQueryResult.queryID().get(), is(notNullValue()));
    assertThatEventually(() -> ((ClientImpl) consistencClient).getSerializedConsistencyVector(), is(notNullValue()));
    final String serializedCV = ((ClientImpl) consistencClient).getSerializedConsistencyVector();
    verifyConsistencyVector(serializedCV);
}
Also used : ClientImpl(io.confluent.ksql.api.client.impl.ClientImpl) Row(io.confluent.ksql.api.client.Row) StreamedRow(io.confluent.ksql.rest.entity.StreamedRow) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) BatchedQueryResult(io.confluent.ksql.api.client.BatchedQueryResult) Test(org.junit.Test)

Example 27 with Row

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

the class ClientIntegrationTest method shouldStreamPullQueryOnEmptyStreamSync.

@Test
public void shouldStreamPullQueryOnEmptyStreamSync() throws Exception {
    // When
    final StreamedQueryResult streamedQueryResult = client.streamQuery("SELECT * FROM " + EMPTY_TEST_STREAM + ";").get();
    // Then
    assertThat(streamedQueryResult.columnNames(), is(TEST_COLUMN_NAMES));
    assertThat(streamedQueryResult.columnTypes(), is(TEST_COLUMN_TYPES));
    assertThat(streamedQueryResult.queryID(), is(notNullValue()));
    final List<Row> results = new LinkedList<>();
    Row row;
    while (true) {
        row = streamedQueryResult.poll();
        if (row == null) {
            break;
        } else {
            results.add(row);
        }
    }
    verifyStreamRows(results, 0);
    assertThatEventually(streamedQueryResult::isComplete, is(true));
}
Also used : Row(io.confluent.ksql.api.client.Row) GenericRow(io.confluent.ksql.GenericRow) LinkedList(java.util.LinkedList) StreamedQueryResult(io.confluent.ksql.api.client.StreamedQueryResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Aggregations

Row (io.confluent.ksql.api.client.Row)27 Test (org.junit.Test)16 IntegrationTest (io.confluent.common.utils.IntegrationTest)13 StreamedQueryResult (io.confluent.ksql.api.client.StreamedQueryResult)10 GenericRow (io.confluent.ksql.GenericRow)8 BatchedQueryResult (io.confluent.ksql.api.client.BatchedQueryResult)7 Matchers.containsString (org.hamcrest.Matchers.containsString)6 KsqlObject (io.confluent.ksql.api.client.KsqlObject)5 ExecutionException (java.util.concurrent.ExecutionException)5 KsqlArray (io.confluent.ksql.api.client.KsqlArray)4 KsqlClientException (io.confluent.ksql.api.client.exception.KsqlClientException)4 BigDecimal (java.math.BigDecimal)4 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 ZooKeeperClientException (kafka.zookeeper.ZooKeeperClientException)3 MigrationException (io.confluent.ksql.tools.migrations.MigrationException)2 JsonArray (io.vertx.core.json.JsonArray)2 JsonObject (io.vertx.core.json.JsonObject)2 ArrayList (java.util.ArrayList)2 AcksPublisher (io.confluent.ksql.api.client.AcksPublisher)1