Search in sources :

Example 1 with TerminateQuery

use of io.confluent.ksql.parser.tree.TerminateQuery in project ksql by confluentinc.

the class StatementExecutor method executeStatement.

private void executeStatement(Statement statement, Command command, CommandId commandId, Map<QueryId, CommandId> terminatedQueries, boolean wasDropped) throws Exception {
    String statementStr = command.getStatement();
    DdlCommandResult result = null;
    String successMessage = "";
    if (statement instanceof DdlStatement) {
        result = ksqlEngine.executeDdlStatement(statementStr, (DdlStatement) statement, command.getKsqlProperties());
    } else if (statement instanceof CreateAsSelect) {
        successMessage = handleCreateAsSelect((CreateAsSelect) statement, command, commandId, terminatedQueries, statementStr, wasDropped);
        if (successMessage == null) {
            return;
        }
    } else if (statement instanceof TerminateQuery) {
        terminateQuery((TerminateQuery) statement);
        successMessage = "Query terminated.";
    } else if (statement instanceof RunScript) {
        handleRunScript(command);
    } else {
        throw new Exception(String.format("Unexpected statement type: %s", statement.getClass().getName()));
    }
    // TODO: change to unified return message
    CommandStatus successStatus = new CommandStatus(CommandStatus.Status.SUCCESS, result != null ? result.getMessage() : successMessage);
    statusStore.put(commandId, successStatus);
    completeStatusFuture(commandId, successStatus);
}
Also used : DdlCommandResult(io.confluent.ksql.ddl.commands.DdlCommandResult) TerminateQuery(io.confluent.ksql.parser.tree.TerminateQuery) DdlStatement(io.confluent.ksql.parser.tree.DdlStatement) CommandStatus(io.confluent.ksql.rest.entity.CommandStatus) RunScript(io.confluent.ksql.parser.tree.RunScript) CreateAsSelect(io.confluent.ksql.parser.tree.CreateAsSelect) WakeupException(org.apache.kafka.common.errors.WakeupException) KsqlException(io.confluent.ksql.util.KsqlException)

Aggregations

DdlCommandResult (io.confluent.ksql.ddl.commands.DdlCommandResult)1 CreateAsSelect (io.confluent.ksql.parser.tree.CreateAsSelect)1 DdlStatement (io.confluent.ksql.parser.tree.DdlStatement)1 RunScript (io.confluent.ksql.parser.tree.RunScript)1 TerminateQuery (io.confluent.ksql.parser.tree.TerminateQuery)1 CommandStatus (io.confluent.ksql.rest.entity.CommandStatus)1 KsqlException (io.confluent.ksql.util.KsqlException)1 WakeupException (org.apache.kafka.common.errors.WakeupException)1