Search in sources :

Example 16 with StreamedQueryResult

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

the class ClientIntegrationTest method shouldStreamPullQueryOnTableAsync.

@Test
public void shouldStreamPullQueryOnTableAsync() throws Exception {
    // When
    final StreamedQueryResult streamedQueryResult = client.streamQuery(PULL_QUERY_ON_TABLE).get();
    // Then
    assertThat(streamedQueryResult.columnNames(), is(PULL_QUERY_COLUMN_NAMES));
    assertThat(streamedQueryResult.columnTypes(), is(PULL_QUERY_COLUMN_TYPES));
    assertThat(streamedQueryResult.queryID(), is(notNullValue()));
    shouldReceiveRows(streamedQueryResult, 1, ClientIntegrationTest::verifyPullQueryRows, true);
    assertThatEventually(streamedQueryResult::isComplete, is(true));
}
Also used : StreamedQueryResult(io.confluent.ksql.api.client.StreamedQueryResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 17 with StreamedQueryResult

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

the class ClientIntegrationTest method shouldStreamPushQueryWithLimitAsync.

@Test
public void shouldStreamPushQueryWithLimitAsync() throws Exception {
    // When
    final StreamedQueryResult streamedQueryResult = client.streamQuery(PUSH_QUERY_WITH_LIMIT).get();
    // Then
    assertThat(streamedQueryResult.columnNames(), is(TEST_COLUMN_NAMES));
    assertThat(streamedQueryResult.columnTypes(), is(TEST_COLUMN_TYPES));
    assertThat(streamedQueryResult.queryID(), is(notNullValue()));
    shouldReceiveStreamRows(streamedQueryResult, true, PUSH_QUERY_LIMIT_NUM_ROWS);
    assertThat(streamedQueryResult.isComplete(), is(true));
}
Also used : StreamedQueryResult(io.confluent.ksql.api.client.StreamedQueryResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 18 with StreamedQueryResult

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

the class ClientIntegrationTest method shouldStreamPullQueryOnTruncatedStreamSync.

@Test
public void shouldStreamPullQueryOnTruncatedStreamSync() throws Exception {
    // double-check to make sure it's really truncated
    truncateTopic(TRUNCATED_TEST_TOPIC);
    // When
    final StreamedQueryResult streamedQueryResult = client.streamQuery("SELECT * FROM " + TRUNCATED_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)

Example 19 with StreamedQueryResult

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

the class ConsistencyOffsetVectorFunctionalTest method shouldRoundTripCVWhenPullQueryOnTableAsync.

@Test
public void shouldRoundTripCVWhenPullQueryOnTableAsync() throws Exception {
    // When
    final StreamedQueryResult streamedQueryResult = consistencClient.streamQuery(PULL_QUERY_ON_TABLE).get();
    // Then
    shouldReceiveRows(streamedQueryResult, 1, // do nothing
    (v) -> {
    }, true);
    assertThatEventually(streamedQueryResult::isComplete, is(true));
    assertThat(((ClientImpl) consistencClient).getSerializedConsistencyVector(), is(notNullValue()));
    final String serializedCV = ((ClientImpl) consistencClient).getSerializedConsistencyVector();
    verifyConsistencyVector(serializedCV);
}
Also used : ClientImpl(io.confluent.ksql.api.client.impl.ClientImpl) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) StreamedQueryResult(io.confluent.ksql.api.client.StreamedQueryResult) Test(org.junit.Test)

Example 20 with StreamedQueryResult

use of io.confluent.ksql.api.client.StreamedQueryResult 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

StreamedQueryResult (io.confluent.ksql.api.client.StreamedQueryResult)20 Test (org.junit.Test)20 IntegrationTest (io.confluent.common.utils.IntegrationTest)16 Row (io.confluent.ksql.api.client.Row)10 GenericRow (io.confluent.ksql.GenericRow)8 LinkedList (java.util.LinkedList)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 KsqlObject (io.confluent.ksql.api.client.KsqlObject)2 KsqlClientException (io.confluent.ksql.api.client.exception.KsqlClientException)2 ClientImpl (io.confluent.ksql.api.client.impl.ClientImpl)2 HashMap (java.util.HashMap)2 ExecutionException (java.util.concurrent.ExecutionException)2 ZooKeeperClientException (kafka.zookeeper.ZooKeeperClientException)2 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)2 KsqlArray (io.confluent.ksql.api.client.KsqlArray)1 BigDecimal (java.math.BigDecimal)1