Search in sources :

Example 16 with PersistentQueryMetadata

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

the class StandaloneExecutor method executeStatements.

private void executeStatements(final String queries) throws Exception {
    final List<QueryMetadata> queryMetadataList = ksqlEngine.createQueries(queries);
    for (QueryMetadata queryMetadata : queryMetadataList) {
        if (queryMetadata instanceof PersistentQueryMetadata) {
            PersistentQueryMetadata persistentQueryMetadata = (PersistentQueryMetadata) queryMetadata;
            persistentQueryMetadata.start();
        } else {
            final String message = String.format("Ignoring statements: %s" + "%nOnly CREATE statements can run in standalone mode.", queryMetadata.getStatementString());
            System.err.println(message);
            log.warn(message);
        }
    }
}
Also used : QueryMetadata(io.confluent.ksql.util.QueryMetadata) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata)

Example 17 with PersistentQueryMetadata

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

the class StandaloneExecutorTest method shouldExecutePersistentQueries.

@Test
public void shouldExecutePersistentQueries() throws Exception {
    final PersistentQueryMetadata query = EasyMock.niceMock(PersistentQueryMetadata.class);
    EasyMock.expect(engine.createQueries(anyString())).andReturn(Collections.singletonList(query));
    query.start();
    EasyMock.expectLastCall();
    EasyMock.replay(query, engine);
    executor.start();
    EasyMock.verify(query);
}
Also used : 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