use of io.confluent.ksql.api.client.StreamedQueryResult in project ksql by confluentinc.
the class ClientMutationIntegrationTest method shouldStreamQueryWithProperties.
@Test
public void shouldStreamQueryWithProperties() throws Exception {
// Given
final Map<String, Object> properties = new HashMap<>();
properties.put("auto.offset.reset", "latest");
final String sql = "SELECT * FROM " + TEST_STREAM + " EMIT CHANGES LIMIT 1;";
final KsqlObject insertRow = new KsqlObject().put("K", new KsqlObject().put("F1", new KsqlArray().add("my_key_shouldStreamQueryWithProperties"))).put("STR", "Value_shouldStreamQueryWithProperties").put("LONG", 2000L).put("DEC", new BigDecimal("12.34")).put("BYTES_", new byte[] { 0, 1, 2 }).put("ARRAY", new KsqlArray().add("v1_shouldStreamQueryWithProperties").add("v2_shouldStreamQueryWithProperties")).put("MAP", new KsqlObject().put("test_name", "shouldStreamQueryWithProperties")).put("STRUCT", new KsqlObject().put("F1", 4)).put("COMPLEX", COMPLEX_FIELD_VALUE).put("TIMESTAMP", "1970-01-01T00:00:00.001").put("DATE", "1970-01-01").put("TIME", "00:00:00");
// When
final StreamedQueryResult queryResult = client.streamQuery(sql, properties).get();
// Then: a newly inserted row arrives
final Row row = assertThatEventually(() -> {
// Potentially try inserting multiple times, in case the query wasn't started by the first time
try {
client.insertInto(TEST_STREAM, insertRow).get();
} catch (final Exception e) {
throw new RuntimeException(e);
}
return queryResult.poll(Duration.ofMillis(10));
}, is(notNullValue()));
assertThat(row.getKsqlObject("K"), is(new KsqlObject().put("F1", new KsqlArray().add("my_key_shouldStreamQueryWithProperties"))));
assertThat(row.getString("STR"), is("Value_shouldStreamQueryWithProperties"));
assertThat(row.getLong("LONG"), is(2000L));
assertThat(row.getDecimal("DEC"), is(new BigDecimal("12.34")));
assertThat(row.getBytes("BYTES_"), is(new byte[] { 0, 1, 2 }));
assertThat(row.getKsqlArray("ARRAY"), is(new KsqlArray().add("v1_shouldStreamQueryWithProperties").add("v2_shouldStreamQueryWithProperties")));
assertThat(row.getKsqlObject("MAP"), is(new KsqlObject().put("test_name", "shouldStreamQueryWithProperties")));
assertThat(row.getKsqlObject("STRUCT"), is(new KsqlObject().put("F1", 4)));
assertThat(row.getKsqlObject("COMPLEX"), is(EXPECTED_COMPLEX_FIELD_VALUE));
assertThat(row.getString("TIMESTAMP"), is("1970-01-01T00:00:00.001"));
assertThat(row.getString("DATE"), is("1970-01-01"));
assertThat(row.getString("TIME"), is("00:00"));
}
use of io.confluent.ksql.api.client.StreamedQueryResult in project ksql by confluentinc.
the class ClientIntegrationTest method shouldStreamPullQueryOnTableSync.
@Test
public void shouldStreamPullQueryOnTableSync() 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()));
final Row row = streamedQueryResult.poll();
verifyPullQueryRow(row);
assertThat(streamedQueryResult.poll(), is(nullValue()));
assertThatEventually(streamedQueryResult::isComplete, is(true));
}
use of io.confluent.ksql.api.client.StreamedQueryResult in project ksql by confluentinc.
the class ConsistencyOffsetVectorFunctionalTest method shouldNotRoundTripCVWhenPullQueryOnTableAsync.
@Test
public void shouldNotRoundTripCVWhenPullQueryOnTableAsync() throws Exception {
// When
final StreamedQueryResult streamedQueryResult = eventualClient.streamQuery(PULL_QUERY_ON_TABLE).get();
// Then
shouldReceiveRows(streamedQueryResult, 1, // do nothing
(v) -> {
}, true);
assertThatEventually(streamedQueryResult::isComplete, is(true));
assertThat(((ClientImpl) eventualClient).getSerializedConsistencyVector(), is(isEmptyString()));
}
use of io.confluent.ksql.api.client.StreamedQueryResult in project ksql by confluentinc.
the class ConsistencyOffsetVectorFunctionalTest method shouldNotRoundTripCVWhenPullQueryOnTableSync.
@Test
public void shouldNotRoundTripCVWhenPullQueryOnTableSync() throws Exception {
// When
final StreamedQueryResult streamedQueryResult = eventualClient.streamQuery(PULL_QUERY_ON_TABLE).get();
streamedQueryResult.poll();
// Then
assertThatEventually(streamedQueryResult::isComplete, is(true));
assertThatEventually(() -> ((ClientImpl) eventualClient).getSerializedConsistencyVector(), is(isEmptyString()));
}
use of io.confluent.ksql.api.client.StreamedQueryResult in project ksql by confluentinc.
the class ConsistencyOffsetVectorFunctionalTest method shouldRoundTripCVWhenPullQueryOnTableSync.
@Test
public void shouldRoundTripCVWhenPullQueryOnTableSync() throws Exception {
// When
final StreamedQueryResult streamedQueryResult = consistencClient.streamQuery(PULL_QUERY_ON_TABLE).get();
streamedQueryResult.poll();
// Then
assertThatEventually(streamedQueryResult::isComplete, is(true));
assertThatEventually(() -> ((ClientImpl) consistencClient).getSerializedConsistencyVector(), is(notNullValue()));
final String serializedCV = ((ClientImpl) consistencClient).getSerializedConsistencyVector();
verifyConsistencyVector(serializedCV);
}
Aggregations