Search in sources :

Example 1 with ExecuteStatementResult

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

the class ClientIntegrationTest method shouldOnlyWarnForDuplicateIfNotExists.

@Test
public void shouldOnlyWarnForDuplicateIfNotExists() throws Exception {
    // When
    ExecuteStatementResult result;
    client.executeStatement("CREATE STREAM FOO (id INT KEY, bar VARCHAR) WITH(value_format='json', kafka_topic='foo', partitions=6);").get();
    client.executeStatement("CREATE STREAM IF NOT EXISTS BAR AS SELECT * FROM FOO EMIT CHANGES;").get();
    result = client.executeStatement("CREATE STREAM IF NOT EXISTS BAR AS SELECT * FROM FOO EMIT CHANGES;").get();
    // Then
    assertThat(result.queryId(), is(Optional.empty()));
}
Also used : ExecuteStatementResult(io.confluent.ksql.api.client.ExecuteStatementResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 2 with ExecuteStatementResult

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

the class ClientMutationIntegrationTest method shouldExecuteDdlDmlStatements.

@Test
public void shouldExecuteDdlDmlStatements() throws Exception {
    // Given
    final String streamName = TEST_STREAM + "_COPY";
    final String csas = "create stream " + streamName + " as select * from " + TEST_STREAM + " emit changes;";
    final int numInitialStreams = 3;
    final int numInitialQueries = 1;
    verifyNumStreams(numInitialStreams);
    verifyNumQueries(numInitialQueries);
    // When: create stream, start persistent query
    final ExecuteStatementResult csasResult = client.executeStatement(csas).get();
    // Then
    verifyNumStreams(numInitialStreams + 1);
    verifyNumQueries(numInitialQueries + 1);
    assertThat(csasResult.queryId(), is(Optional.of(findQueryIdForSink(streamName))));
    // When: terminate persistent query
    final String queryId = csasResult.queryId().get();
    final ExecuteStatementResult terminateResult = client.executeStatement("terminate " + queryId + ";").get();
    // Then
    verifyNumQueries(numInitialQueries);
    assertThat(terminateResult.queryId(), is(Optional.empty()));
    // When: drop stream
    final ExecuteStatementResult dropStreamResult = client.executeStatement("drop stream " + streamName + ";").get();
    // Then
    verifyNumStreams(numInitialStreams);
    assertThat(dropStreamResult.queryId(), is(Optional.empty()));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) ExecuteStatementResult(io.confluent.ksql.api.client.ExecuteStatementResult) IntegrationTest(io.confluent.common.utils.IntegrationTest) Test(org.junit.Test)

Aggregations

IntegrationTest (io.confluent.common.utils.IntegrationTest)2 ExecuteStatementResult (io.confluent.ksql.api.client.ExecuteStatementResult)2 Test (org.junit.Test)2 Matchers.containsString (org.hamcrest.Matchers.containsString)1