Search in sources :

Example 1 with PersistentQueryMetadata

use of io.confluent.ksql.util.PersistentQueryMetadata in project ksql by confluentinc.

the class JsonFormatTest method executePersistentQuery.

private void executePersistentQuery(String queryString) throws Exception {
    final QueryMetadata queryMetadata = ksqlEngine.buildMultipleQueries(queryString, Collections.emptyMap()).get(0);
    queryMetadata.getKafkaStreams().start();
    queryId = ((PersistentQueryMetadata) queryMetadata).getId();
}
Also used : PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) QueryMetadata(io.confluent.ksql.util.QueryMetadata)

Example 2 with PersistentQueryMetadata

use of io.confluent.ksql.util.PersistentQueryMetadata in project ksql by confluentinc.

the class SecureIntegrationTest method executePersistentQuery.

private void executePersistentQuery(final String queryString, final Object... params) throws Exception {
    final String query = String.format(queryString, params);
    final QueryMetadata queryMetadata = ksqlEngine.buildMultipleQueries(query, Collections.emptyMap()).get(0);
    queryMetadata.getKafkaStreams().start();
    queryId = ((PersistentQueryMetadata) queryMetadata).getId();
}
Also used : PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) QueryMetadata(io.confluent.ksql.util.QueryMetadata)

Example 3 with PersistentQueryMetadata

use of io.confluent.ksql.util.PersistentQueryMetadata in project ksql by confluentinc.

the class KsqlContextTest method getQueryMetadata.

private List<QueryMetadata> getQueryMetadata(QueryId queryid, DataSource.DataSourceType type) {
    KafkaStreams queryStreams = mock(KafkaStreams.class);
    queryStreams.start();
    expectLastCall();
    PersistentQueryMetadata persistentQueryMetadata = new PersistentQueryMetadata(queryid.toString(), queryStreams, null, "", queryid, type, "KSQL_query_" + queryid, null, null, null, null);
    return Arrays.asList(persistentQueryMetadata);
}
Also used : KafkaStreams(org.apache.kafka.streams.KafkaStreams) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata)

Example 4 with PersistentQueryMetadata

use of io.confluent.ksql.util.PersistentQueryMetadata in project ksql by confluentinc.

the class KsqlContextTest method shouldRunSimpleStatements.

@Test
public void shouldRunSimpleStatements() throws Exception {
    AdminClient adminClient = mock(AdminClient.class);
    KafkaTopicClient kafkaTopicClient = mock(KafkaTopicClientImpl.class);
    KsqlEngine ksqlEngine = mock(KsqlEngine.class);
    Map<QueryId, PersistentQueryMetadata> liveQueryMap = new HashMap<>();
    KsqlContext ksqlContext = new KsqlContext(adminClient, kafkaTopicClient, ksqlEngine);
    expect(ksqlEngine.buildMultipleQueries(statement1, Collections.emptyMap())).andReturn(Collections.emptyList());
    expect(ksqlEngine.buildMultipleQueries(statement2, Collections.emptyMap())).andReturn(getQueryMetadata(new QueryId("CSAS_BIGORDERS"), DataSource.DataSourceType.KSTREAM));
    expect(ksqlEngine.getPersistentQueries()).andReturn(liveQueryMap);
    replay(ksqlEngine);
    ksqlContext.sql(statement1);
    ksqlContext.sql(statement2);
    verify(ksqlEngine);
}
Also used : KafkaTopicClient(io.confluent.ksql.util.KafkaTopicClient) HashMap(java.util.HashMap) QueryId(io.confluent.ksql.query.QueryId) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) AdminClient(org.apache.kafka.clients.admin.AdminClient) Test(org.junit.Test)

Example 5 with PersistentQueryMetadata

use of io.confluent.ksql.util.PersistentQueryMetadata in project ksql by confluentinc.

the class KsqlEngineTest method shouldCreatePersistentQueries.

@Test
public void shouldCreatePersistentQueries() throws Exception {
    final List<QueryMetadata> queries = ksqlEngine.createQueries("create table bar as select * from test2;" + "create table foo as select * from test2;");
    assertThat(queries.size(), equalTo(2));
    final PersistentQueryMetadata queryOne = (PersistentQueryMetadata) queries.get(0);
    final PersistentQueryMetadata queryTwo = (PersistentQueryMetadata) queries.get(1);
    assertThat(queryOne.getEntity(), equalTo("BAR"));
    assertThat(queryTwo.getEntity(), equalTo("FOO"));
}
Also used : QueryMetadata(io.confluent.ksql.util.QueryMetadata) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) Test(org.junit.Test)

Aggregations

PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)17 QueryMetadata (io.confluent.ksql.util.QueryMetadata)11 QueryId (io.confluent.ksql.query.QueryId)6 KsqlException (io.confluent.ksql.util.KsqlException)6 CreateStreamCommand (io.confluent.ksql.ddl.commands.CreateStreamCommand)3 CreateTableCommand (io.confluent.ksql.ddl.commands.CreateTableCommand)3 DdlCommandExec (io.confluent.ksql.ddl.commands.DdlCommandExec)3 DropSourceCommand (io.confluent.ksql.ddl.commands.DropSourceCommand)3 DropTopicCommand (io.confluent.ksql.ddl.commands.DropTopicCommand)3 RegisterTopicCommand (io.confluent.ksql.ddl.commands.RegisterTopicCommand)3 KsqlStructuredDataOutputNode (io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode)3 KafkaTopicClient (io.confluent.ksql.util.KafkaTopicClient)3 Pair (io.confluent.ksql.util.Pair)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DdlCommandResult (io.confluent.ksql.ddl.commands.DdlCommandResult)2 KsqlParser (io.confluent.ksql.parser.KsqlParser)2 SqlBaseParser (io.confluent.ksql.parser.SqlBaseParser)2 CreateAsSelect (io.confluent.ksql.parser.tree.CreateAsSelect)2 CreateStream (io.confluent.ksql.parser.tree.CreateStream)2