This is an automated email from the ASF dual-hosted git repository.

ivandasch pushed a commit to branch sql-calcite
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/sql-calcite by this push:
     new e533ed1  IGNITE-15423 Implement KILL queries support - Fixes #9412.
e533ed1 is described below

commit e533ed10237ef8c16815ecd54c490c194b3cef9d
Author: Ivan Daschinsky <[email protected]>
AuthorDate: Fri Sep 17 16:53:05 2021 +0300

    IGNITE-15423 Implement KILL queries support - Fixes #9412.
    
    Signed-off-by: Ivan Daschinsky <[email protected]>
---
 modules/calcite/src/main/codegen/config.fmpp       |  19 +-
 .../src/main/codegen/includes/parserImpls.ftl      | 123 +++++++++
 .../prepare/ddl/SqlToNativeCommandConverter.java   |  57 +++-
 .../query/calcite/sql/IgniteSqlKill.java           |  81 ++++++
 .../calcite/sql/kill/IgniteSqlKillComputeTask.java |  68 +++++
 .../sql/kill/IgniteSqlKillContinuousQuery.java     |  82 ++++++
 .../calcite/sql/kill/IgniteSqlKillScanQuery.java   |  95 +++++++
 .../calcite/sql/kill/IgniteSqlKillService.java     |  68 +++++
 .../calcite/sql/kill/IgniteSqlKillTransaction.java |  68 +++++
 .../query/calcite/util/IgniteResource.java         |   9 +
 .../integration/KillCommandDdlIntegrationTest.java | 304 +++++++++++++++++++++
 .../query/calcite/sql/SqlDdlParserTest.java        | 103 +++++++
 .../ignite/testsuites/IntegrationTestSuite.java    |   2 +
 .../sql/command/SqlKillComputeTaskCommand.java     |  14 +
 .../sql/command/SqlKillContinuousQueryCommand.java |  17 ++
 .../sql/command/SqlKillScanQueryCommand.java       |  18 ++
 .../sql/command/SqlKillServiceCommand.java         |  14 +
 .../sql/command/SqlKillTransactionCommand.java     |  14 +
 18 files changed, 1154 insertions(+), 2 deletions(-)

diff --git a/modules/calcite/src/main/codegen/config.fmpp 
b/modules/calcite/src/main/codegen/config.fmpp
index 302025b..86ad11c 100644
--- a/modules/calcite/src/main/codegen/config.fmpp
+++ b/modules/calcite/src/main/codegen/config.fmpp
@@ -27,11 +27,13 @@ data: {
     # List of additional classes and packages to import.
     # Example: "org.apache.calcite.sql.*", "java.util.List".
     imports: [
+      "java.util.UUID",
       "org.apache.calcite.sql.SqlCreate",
       "org.apache.calcite.sql.SqlDrop",
       "org.apache.calcite.sql.SqlLiteral",
       "org.apache.calcite.schema.ColumnStrategy",
       
"org.apache.ignite.internal.processors.query.calcite.util.IgniteResource",
+      "org.apache.ignite.lang.IgniteUuid",
       "org.apache.calcite.sql.ddl.SqlDdlNodes",
     ]
 
@@ -57,6 +59,11 @@ data: {
       "LOGGING"
       "NOLOGGING"
       "PASSWORD"
+      "KILL"
+      "SCAN"
+      "CONTINUOUS"
+      "SERVICE"
+      "COMPUTE"
     ]
 
     # List of non-reserved keywords to add;
@@ -79,6 +86,11 @@ data: {
       "LOGGING"
       "NOLOGGING"
       "PASSWORD"
+      "KILL"
+      "SCAN"
+      "CONTINUOUS"
+      "SERVICE"
+      "COMPUTE"
 
       # The following keywords are reserved in core Calcite,
       # are reserved in some version of SQL,
@@ -590,7 +602,12 @@ data: {
     # Example: "SqlShowDatabases()", "SqlShowTables()".
     statementParserMethods: [
       "SqlAlterTable()",
-      "SqlAlterUser()"
+      "SqlAlterUser()",
+      "SqlKillScanQuery()"
+      "SqlKillContinuousQuery()"
+      "SqlKillService()"
+      "SqlKillTransaction()"
+      "SqlKillComputeTask()"
     ]
 
     # List of methods for parsing extensions to "CREATE [OR REPLACE]" calls.
diff --git a/modules/calcite/src/main/codegen/includes/parserImpls.ftl 
b/modules/calcite/src/main/codegen/includes/parserImpls.ftl
index d5e284c..62c80ca 100644
--- a/modules/calcite/src/main/codegen/includes/parserImpls.ftl
+++ b/modules/calcite/src/main/codegen/includes/parserImpls.ftl
@@ -397,3 +397,126 @@ SqlDrop SqlDropUser(Span s, boolean replace) :
     < NEGATE: "!" >
 |   < TILDE: "~" >
 }
+
+SqlNumericLiteral SignedIntegerLiteral() :
+{
+    final Span s;
+}
+{
+    <PLUS> <UNSIGNED_INTEGER_LITERAL> {
+        return SqlLiteral.createExactNumeric(token.image, getPos());
+    }
+|
+    <MINUS> { s = span(); } <UNSIGNED_INTEGER_LITERAL> {
+        return 
SqlLiteral.createNegative(SqlLiteral.createExactNumeric(token.image, getPos()), 
s.end(this));
+    }
+|
+    <UNSIGNED_INTEGER_LITERAL> {
+        return SqlLiteral.createExactNumeric(token.image, getPos());
+    }
+}
+
+SqlCharStringLiteral UuidLiteral():
+{
+    final Span s;
+    final String rawUuuid;
+}
+{
+    <QUOTED_STRING> {
+        String rawUuid = SqlParserUtil.parseString(token.image);
+        try {
+            UUID.fromString(rawUuid);
+            return SqlLiteral.createCharString(rawUuid, getPos());
+        }
+        catch (Exception e) {
+            throw SqlUtil.newContextException(getPos(), 
IgniteResource.INSTANCE.illegalUuid(rawUuid));
+        }
+    }
+}
+
+SqlCharStringLiteral IgniteUuidLiteral():
+{
+    final Span s;
+    final String rawUuuid;
+}
+{
+    <QUOTED_STRING> {
+        String rawUuid = SqlParserUtil.parseString(token.image);
+        try {
+            IgniteUuid.fromString(rawUuid);
+            return SqlLiteral.createCharString(rawUuid, getPos());
+        }
+        catch (Exception e) {
+            throw SqlUtil.newContextException(getPos(), 
IgniteResource.INSTANCE.illegalIgniteUuid(rawUuid));
+        }
+    }
+}
+
+SqlNode SqlKillScanQuery():
+{
+    final Span s;
+    final SqlCharStringLiteral originNodeId;
+    final SqlCharStringLiteral cacheName;
+    final SqlNumericLiteral queryId;
+}
+{
+    <KILL> { s = span(); } <SCAN>
+    originNodeId = UuidLiteral()
+    <QUOTED_STRING> {
+        cacheName = 
SqlLiteral.createCharString(SqlParserUtil.parseString(token.image), getPos());
+    }
+    queryId = SignedIntegerLiteral() {
+        return IgniteSqlKill.createScanQueryKill(s.end(this), originNodeId, 
cacheName, queryId);
+    }
+}
+
+SqlNode SqlKillContinuousQuery():
+{
+    final Span s;
+    final SqlCharStringLiteral originNodeId;
+    final SqlCharStringLiteral routineId;
+}
+{
+    <KILL> { s = span(); } <CONTINUOUS>
+    originNodeId = UuidLiteral()
+    routineId = UuidLiteral() {
+        return IgniteSqlKill.createContinuousQueryKill(s.end(this), 
originNodeId, routineId);
+    }
+}
+
+SqlNode SqlKillTransaction():
+{
+    final Span s;
+    final SqlCharStringLiteral xid;
+}
+{
+    <KILL> { s = span(); } <TRANSACTION>
+    xid = IgniteUuidLiteral() {
+        return IgniteSqlKill.createTransactionKill(s.end(this), xid);
+    }
+}
+
+SqlNode SqlKillService():
+{
+    final Span s;
+    final SqlCharStringLiteral srvName;
+}
+{
+    <KILL> { s = span(); } <SERVICE>
+    <QUOTED_STRING> {
+        srvName = 
SqlLiteral.createCharString(SqlParserUtil.parseString(token.image), getPos());
+        return IgniteSqlKill.createServiceKill(s.end(this), srvName);
+    }
+}
+
+SqlNode SqlKillComputeTask():
+{
+    final Span s;
+    final SqlCharStringLiteral sesId;
+}
+{
+    <KILL> { s = span(); } <COMPUTE>
+    sesId = IgniteUuidLiteral() {
+        return IgniteSqlKill.createComputeTaskKill(s.end(this), sesId);
+    }
+}
diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/ddl/SqlToNativeCommandConverter.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/ddl/SqlToNativeCommandConverter.java
index 2e927ab..2108a3a 100644
--- 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/ddl/SqlToNativeCommandConverter.java
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/ddl/SqlToNativeCommandConverter.java
@@ -19,6 +19,7 @@ package 
org.apache.ignite.internal.processors.query.calcite.prepare.ddl;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.UUID;
 import org.apache.calcite.sql.SqlCall;
 import org.apache.calcite.sql.SqlDdl;
 import org.apache.calcite.sql.SqlIdentifier;
@@ -34,6 +35,12 @@ import 
org.apache.ignite.internal.processors.query.calcite.sql.IgniteSqlCreateIn
 import 
org.apache.ignite.internal.processors.query.calcite.sql.IgniteSqlCreateUser;
 import 
org.apache.ignite.internal.processors.query.calcite.sql.IgniteSqlDropIndex;
 import 
org.apache.ignite.internal.processors.query.calcite.sql.IgniteSqlDropUser;
+import org.apache.ignite.internal.processors.query.calcite.sql.IgniteSqlKill;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillComputeTask;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillContinuousQuery;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillScanQuery;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillService;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillTransaction;
 import org.apache.ignite.internal.sql.command.SqlAlterTableCommand;
 import org.apache.ignite.internal.sql.command.SqlAlterUserCommand;
 import org.apache.ignite.internal.sql.command.SqlCommand;
@@ -42,6 +49,12 @@ import 
org.apache.ignite.internal.sql.command.SqlCreateUserCommand;
 import org.apache.ignite.internal.sql.command.SqlDropIndexCommand;
 import org.apache.ignite.internal.sql.command.SqlDropUserCommand;
 import org.apache.ignite.internal.sql.command.SqlIndexColumn;
+import org.apache.ignite.internal.sql.command.SqlKillComputeTaskCommand;
+import org.apache.ignite.internal.sql.command.SqlKillContinuousQueryCommand;
+import org.apache.ignite.internal.sql.command.SqlKillScanQueryCommand;
+import org.apache.ignite.internal.sql.command.SqlKillServiceCommand;
+import org.apache.ignite.internal.sql.command.SqlKillTransactionCommand;
+import org.apache.ignite.lang.IgniteUuid;
 
 import static 
org.apache.ignite.internal.processors.query.calcite.util.PlanUtils.deriveObjectName;
 import static 
org.apache.ignite.internal.processors.query.calcite.util.PlanUtils.deriveSchemaName;
@@ -59,7 +72,8 @@ public class SqlToNativeCommandConverter {
             || sqlCmd instanceof IgniteSqlAlterTable
             || sqlCmd instanceof IgniteSqlCreateUser
             || sqlCmd instanceof IgniteSqlAlterUser
-            || sqlCmd instanceof IgniteSqlDropUser;
+            || sqlCmd instanceof IgniteSqlDropUser
+            || sqlCmd instanceof IgniteSqlKill;
     }
 
     /**
@@ -88,6 +102,8 @@ public class SqlToNativeCommandConverter {
             return convertAlterUser((IgniteSqlAlterUser)cmd, pctx);
         else if (cmd instanceof IgniteSqlDropUser)
             return convertDropUser((IgniteSqlDropUser)cmd, pctx);
+        else if (cmd instanceof IgniteSqlKill)
+            return convertKill((IgniteSqlKill)cmd, pctx);
 
         throw new IgniteSQLException("Unsupported native operation [" +
             "cmdName=" + (cmd == null ? null : cmd.getClass().getSimpleName()) 
+ "; " +
@@ -165,4 +181,43 @@ public class SqlToNativeCommandConverter {
     private static SqlDropUserCommand convertDropUser(IgniteSqlDropUser 
sqlCmd, PlanningContext ctx) {
         return new SqlDropUserCommand(sqlCmd.user().getSimple());
     }
+
+    /**
+     * Converts KILL ... command.
+     */
+    private static SqlCommand convertKill(IgniteSqlKill cmd, PlanningContext 
pctx) {
+        if (cmd instanceof IgniteSqlKillScanQuery) {
+            IgniteSqlKillScanQuery cmd0 = (IgniteSqlKillScanQuery)cmd;
+            return new SqlKillScanQueryCommand(
+                UUID.fromString(cmd0.nodeId().getValueAs(String.class)),
+                cmd0.cacheName().getValueAs(String.class),
+                cmd0.queryId().longValue(true)
+            );
+        }
+        else if (cmd instanceof IgniteSqlKillContinuousQuery) {
+            IgniteSqlKillContinuousQuery cmd0 = 
(IgniteSqlKillContinuousQuery)cmd;
+            return new SqlKillContinuousQueryCommand(
+                UUID.fromString(cmd0.nodeId().getValueAs(String.class)),
+                UUID.fromString(cmd0.routineId().getValueAs(String.class))
+            );
+        }
+        else if (cmd instanceof IgniteSqlKillService) {
+            IgniteSqlKillService cmd0 = (IgniteSqlKillService)cmd;
+            return new 
SqlKillServiceCommand(cmd0.serviceName().getValueAs(String.class));
+        }
+        else if (cmd instanceof IgniteSqlKillTransaction) {
+            IgniteSqlKillTransaction cmd0 = (IgniteSqlKillTransaction)cmd;
+            return new 
SqlKillTransactionCommand(cmd0.xid().getValueAs(String.class));
+        }
+        else if (cmd instanceof IgniteSqlKillComputeTask) {
+            IgniteSqlKillComputeTask cmd0 = ( IgniteSqlKillComputeTask)cmd;
+            IgniteUuid sessId = 
IgniteUuid.fromString(cmd0.sessionId().getValueAs(String.class));
+            return new SqlKillComputeTaskCommand(sessId);
+        }
+        else {
+            throw new IgniteSQLException("Unsupported native operation [" +
+                "cmdName=" + (cmd == null ? null : 
cmd.getClass().getSimpleName()) + "; " +
+                "querySql=\"" + pctx.query() + "\"]", 
IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
+        }
+    }
 }
diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/IgniteSqlKill.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/IgniteSqlKill.java
new file mode 100644
index 0000000..a692324
--- /dev/null
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/IgniteSqlKill.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.query.calcite.sql;
+
+import org.apache.calcite.sql.SqlCharStringLiteral;
+import org.apache.calcite.sql.SqlDdl;
+import org.apache.calcite.sql.SqlNumericLiteral;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillComputeTask;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillContinuousQuery;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillScanQuery;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillService;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillTransaction;
+
+/**
+ * Abstract base class for KILL queries.
+ */
+public abstract class IgniteSqlKill extends SqlDdl {
+    /** */
+    protected IgniteSqlKill(SqlOperator operator, SqlParserPos pos) {
+        super(operator, pos);
+    }
+
+    /** */
+    public static IgniteSqlKill createScanQueryKill(
+        SqlParserPos pos,
+        SqlCharStringLiteral nodeId,
+        SqlCharStringLiteral cacheName,
+        SqlNumericLiteral qryId
+    ) {
+        return new IgniteSqlKillScanQuery(pos, nodeId, cacheName, qryId);
+    }
+
+    /** */
+    public static IgniteSqlKill createContinuousQueryKill(
+        SqlParserPos pos,
+        SqlCharStringLiteral nodeId,
+        SqlCharStringLiteral routineId
+    ) {
+        return new IgniteSqlKillContinuousQuery(pos, nodeId, routineId);
+    }
+
+    /** */
+    public static IgniteSqlKill createServiceKill(
+        SqlParserPos pos,
+        SqlCharStringLiteral srvName
+    ) {
+        return new IgniteSqlKillService(pos, srvName);
+    }
+
+    /** */
+    public static IgniteSqlKill createTransactionKill(
+        SqlParserPos pos,
+        SqlCharStringLiteral xid
+    ) {
+        return new IgniteSqlKillTransaction(pos, xid);
+    }
+
+    /** */
+    public static IgniteSqlKill createComputeTaskKill(
+        SqlParserPos pos,
+        SqlCharStringLiteral sesId
+    ) {
+        return new IgniteSqlKillComputeTask(pos, sesId);
+    }
+}
diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillComputeTask.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillComputeTask.java
new file mode 100644
index 0000000..57e0d1d
--- /dev/null
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillComputeTask.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.query.calcite.sql.kill;
+
+import java.util.List;
+import java.util.Objects;
+import org.apache.calcite.sql.SqlCharStringLiteral;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.util.ImmutableNullableList;
+import org.apache.ignite.internal.processors.query.calcite.sql.IgniteSqlKill;
+
+/**
+ * Parse tree for {@code KILL COMPUTE} statement.
+ */
+public class IgniteSqlKillComputeTask extends IgniteSqlKill {
+    /** */
+    private static final SqlOperator OPERATOR = new SqlSpecialOperator("KILL 
COMPUTE", SqlKind.OTHER_DDL);
+
+    /**  */
+    private final SqlCharStringLiteral sesId;
+
+    /** */
+    public IgniteSqlKillComputeTask(
+        SqlParserPos pos,
+        SqlCharStringLiteral sesId
+    ) {
+        super(OPERATOR, pos);
+        this.sesId = Objects.requireNonNull(sesId, "sesId");
+
+    }
+
+    /** {@inheritDoc} */
+    @Override public List<SqlNode> getOperandList() {
+        return ImmutableNullableList.of(sesId);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unparse(SqlWriter writer, int leftPrec, int 
rightPrec) {
+        writer.keyword(getOperator().getName());
+        sesId.unparse(writer, 0, 0);
+    }
+
+    /**
+     * @return Compute task session id.
+     */
+    public SqlCharStringLiteral sessionId() {
+        return sesId;
+    }
+}
diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillContinuousQuery.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillContinuousQuery.java
new file mode 100644
index 0000000..4f6253f
--- /dev/null
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillContinuousQuery.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.query.calcite.sql.kill;
+
+import java.util.List;
+import java.util.Objects;
+import org.apache.calcite.sql.SqlCharStringLiteral;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.util.ImmutableNullableList;
+import org.apache.ignite.internal.processors.query.calcite.sql.IgniteSqlKill;
+
+/**
+ * Parse tree for {@code KILL CONTINUOUS} statement.
+ */
+public class IgniteSqlKillContinuousQuery extends IgniteSqlKill {
+    /** */
+    private static final SqlOperator OPERATOR = new SqlSpecialOperator("KILL 
CONTINUOUS", SqlKind.OTHER_DDL);
+
+    /**  */
+    private final SqlCharStringLiteral nodeId;
+
+    /** */
+    private final SqlCharStringLiteral routineId;
+
+    /** */
+    public IgniteSqlKillContinuousQuery(
+        SqlParserPos pos,
+        SqlCharStringLiteral nodeId,
+        SqlCharStringLiteral routineId
+    ) {
+        super(OPERATOR, pos);
+        this.nodeId = Objects.requireNonNull(nodeId, "nodeId");
+        this.routineId = Objects.requireNonNull(routineId, "routineId");
+
+    }
+
+    /** {@inheritDoc} */
+    @Override public List<SqlNode> getOperandList() {
+        return ImmutableNullableList.of(nodeId, routineId);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unparse(SqlWriter writer, int leftPrec, int 
rightPrec) {
+        writer.keyword(getOperator().getName());
+        nodeId.unparse(writer, 0, 0);
+        routineId.unparse(writer, 0, 0);
+    }
+
+    /**
+     * @return Node id.
+     */
+    public SqlCharStringLiteral nodeId() {
+        return nodeId;
+    }
+
+    /**
+     * @return Routine id.
+     */
+    public SqlCharStringLiteral routineId() {
+        return routineId;
+    }
+}
+
diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillScanQuery.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillScanQuery.java
new file mode 100644
index 0000000..1688805
--- /dev/null
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillScanQuery.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.query.calcite.sql.kill;
+
+import java.util.List;
+import java.util.Objects;
+import org.apache.calcite.sql.SqlCharStringLiteral;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNumericLiteral;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.util.ImmutableNullableList;
+import org.apache.ignite.internal.processors.query.calcite.sql.IgniteSqlKill;
+
+/**
+ * Parse tree for {@code KILL SCAN} statement.
+ */
+public class IgniteSqlKillScanQuery extends IgniteSqlKill {
+    /** */
+    private static final SqlOperator OPERATOR = new SqlSpecialOperator("KILL 
SCAN", SqlKind.OTHER_DDL);
+
+    /**  */
+    private final SqlCharStringLiteral nodeId;
+
+    /** */
+    private final SqlCharStringLiteral cacheName;
+
+    /** */
+    private final SqlNumericLiteral qryId;
+
+    /** */
+    public IgniteSqlKillScanQuery(
+        SqlParserPos pos,
+        SqlCharStringLiteral nodeId,
+        SqlCharStringLiteral cacheName,
+        SqlNumericLiteral qryId
+    ) {
+        super(OPERATOR, pos);
+        this.nodeId = Objects.requireNonNull(nodeId, "nodeId");
+        this.cacheName = Objects.requireNonNull(cacheName, "cacheName");
+        this.qryId = Objects.requireNonNull(qryId, "qryId");
+
+    }
+
+    /** {@inheritDoc} */
+    @Override public List<SqlNode> getOperandList() {
+        return ImmutableNullableList.of(nodeId, cacheName, qryId);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unparse(SqlWriter writer, int leftPrec, int 
rightPrec) {
+        writer.keyword(getOperator().getName());
+        nodeId.unparse(writer, 0, 0);
+        cacheName.unparse(writer, 0, 0);
+        qryId.unparse(writer, 0, 0);
+    }
+
+    /**
+     * @return Node id.
+     */
+    public SqlCharStringLiteral nodeId() {
+        return nodeId;
+    }
+
+    /**
+     * @return Cache name.
+     */
+    public SqlCharStringLiteral cacheName() {
+        return cacheName;
+    }
+
+    /**
+     * @return Query id.
+     */
+    public SqlNumericLiteral queryId() {
+        return qryId;
+    }
+}
diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillService.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillService.java
new file mode 100644
index 0000000..14f06ba
--- /dev/null
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillService.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.query.calcite.sql.kill;
+
+import java.util.List;
+import java.util.Objects;
+import org.apache.calcite.sql.SqlCharStringLiteral;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.util.ImmutableNullableList;
+import org.apache.ignite.internal.processors.query.calcite.sql.IgniteSqlKill;
+
+/**
+ * Parse tree for {@code KILL SERVICE} statement.
+ */
+public class IgniteSqlKillService extends IgniteSqlKill {
+    /** */
+    private static final SqlOperator OPERATOR = new SqlSpecialOperator("KILL 
SERVICE", SqlKind.OTHER_DDL);
+
+    /**  */
+    private final SqlCharStringLiteral srvName;
+
+    /** */
+    public IgniteSqlKillService(
+        SqlParserPos pos,
+        SqlCharStringLiteral srvName
+    ) {
+        super(OPERATOR, pos);
+        this.srvName = Objects.requireNonNull(srvName, "srvName");
+
+    }
+
+    /** {@inheritDoc} */
+    @Override public List<SqlNode> getOperandList() {
+        return ImmutableNullableList.of(srvName);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unparse(SqlWriter writer, int leftPrec, int 
rightPrec) {
+        writer.keyword(getOperator().getName());
+        srvName.unparse(writer, 0, 0);
+    }
+
+    /**
+     * @return Service name.
+     */
+    public SqlCharStringLiteral serviceName() {
+        return srvName;
+    }
+}
diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillTransaction.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillTransaction.java
new file mode 100644
index 0000000..5308652
--- /dev/null
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/sql/kill/IgniteSqlKillTransaction.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.query.calcite.sql.kill;
+
+import java.util.List;
+import java.util.Objects;
+import org.apache.calcite.sql.SqlCharStringLiteral;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.util.ImmutableNullableList;
+import org.apache.ignite.internal.processors.query.calcite.sql.IgniteSqlKill;
+
+/**
+ * Parse tree for {@code KILL TRANSACTION} statement.
+ */
+public class IgniteSqlKillTransaction extends IgniteSqlKill {
+    /** */
+    private static final SqlOperator OPERATOR = new SqlSpecialOperator("KILL 
TRANSACTION", SqlKind.OTHER_DDL);
+
+    /**  */
+    private final SqlCharStringLiteral xid;
+
+    /** */
+    public IgniteSqlKillTransaction(
+        SqlParserPos pos,
+        SqlCharStringLiteral xid
+    ) {
+        super(OPERATOR, pos);
+        this.xid = Objects.requireNonNull(xid, "xid");
+
+    }
+
+    /** {@inheritDoc} */
+    @Override public List<SqlNode> getOperandList() {
+        return ImmutableNullableList.of(xid);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unparse(SqlWriter writer, int leftPrec, int 
rightPrec) {
+        writer.keyword(getOperator().getName());
+        xid.unparse(writer, 0, 0);
+    }
+
+    /**
+     * @return Transaction's xid.
+     */
+    public SqlCharStringLiteral xid() {
+        return xid;
+    }
+}
diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/IgniteResource.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/IgniteResource.java
index ae24367..cd5edb9 100644
--- 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/IgniteResource.java
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/IgniteResource.java
@@ -44,6 +44,15 @@ public interface IgniteResource {
         "(" + Integer.MAX_VALUE + ")." )
     Resources.ExInst<SqlValidatorException> correctIntegerLimit(String a0);
 
+    /** */
     @Resources.BaseMessage("Option ''{0}'' has already been defined")
     Resources.ExInst<SqlValidatorException> optionAlreadyDefined(String 
optName);
+
+    /** */
+    @Resources.BaseMessage("Illegal value ''{0}''. The value must be UUID")
+    Resources.ExInst<SqlValidatorException> illegalUuid(String value);
+
+    /** */
+    @Resources.BaseMessage("Illegal value ''{0}''. The value must be 
IgniteUuid")
+    Resources.ExInst<SqlValidatorException> illegalIgniteUuid(String value);
 }
diff --git 
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KillCommandDdlIntegrationTest.java
 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KillCommandDdlIntegrationTest.java
new file mode 100644
index 0000000..3e4a690
--- /dev/null
+++ 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/KillCommandDdlIntegrationTest.java
@@ -0,0 +1,304 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.query.calcite.integration;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+import javax.cache.Cache;
+import javax.cache.event.CacheEntryEvent;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceConfiguration;
+import org.apache.ignite.services.ServiceContext;
+import org.apache.ignite.spi.systemview.view.ComputeJobView;
+import org.apache.ignite.spi.systemview.view.ContinuousQueryView;
+import org.apache.ignite.spi.systemview.view.ScanQueryView;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.transactions.Transaction;
+import org.junit.Test;
+
+import static 
org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW;
+import static 
org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.CQ_SYS_VIEW;
+import static 
org.apache.ignite.internal.processors.job.GridJobProcessor.JOBS_VIEW;
+import static 
org.apache.ignite.internal.processors.service.IgniteServiceProcessor.SVCS_VIEW;
+import static 
org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/**
+ * Tests for KILL queries.
+ */
+public class KillCommandDdlIntegrationTest extends AbstractDdlIntegrationTest {
+    /** Page size. */
+    public static final int PAGE_SZ = 5;
+
+    /** Number of pages to insert. */
+    public static final int PAGES_CNT = 1000;
+
+    /** Operations timeout. */
+    public static final int TIMEOUT = 10_000;
+
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        IgniteCache<Object, Object> cache = client.getOrCreateCache(
+            new 
CacheConfiguration<>(DEFAULT_CACHE_NAME).setIndexedTypes(Integer.class, 
Integer.class)
+                .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
+
+        // There must be enough cache entries to keep scan query cursor opened.
+        // Cursor may be concurrently closed when all the data retrieved.
+        for (int i = 0; i < PAGES_CNT * PAGE_SZ; i++)
+            cache.put(i, i);
+    }
+
+    /** */
+    @Override public void cleanUp() {
+        // No-op.
+    }
+
+    /** */
+    @Test
+    public void testCancelScanQuery() {
+        IgniteCache<Object, Object> cache = client.cache(DEFAULT_CACHE_NAME);
+
+        QueryCursor<Cache.Entry<Object, Object>> scanQry = cache.query(new 
ScanQuery<>().setPageSize(PAGE_SZ));
+        Iterator<Cache.Entry<Object, Object>> scanQryIter = scanQry.iterator();
+
+        // Fetch first entry and therefore caching first page.
+        assertNotNull(scanQryIter.next());
+
+        SystemView<ScanQueryView> queries = 
grid(0).context().systemView().view(SCAN_QRY_SYS_VIEW);
+        assertEquals(1, queries.size());
+        ScanQueryView qryView = queries.iterator().next();
+
+        long qryId = qryView.queryId();
+        UUID originNodeId = qryView.originNodeId();
+
+        executeSql(client, "KILL SCAN '" + originNodeId + "' '" + 
DEFAULT_CACHE_NAME + "' " + qryId);
+
+        // Fetch all cached entries.
+        for (int i = 0; i < PAGE_SZ * servers().size() - 1; i++)
+            assertNotNull(scanQryIter.next());
+
+        // Fetch of the next page should throw the exception.
+        assertThrowsWithCause(scanQryIter::next, IgniteCheckedException.class);
+    }
+
+    /** */
+    @Test
+    public void testCancelComputeTask() throws Exception {
+        CountDownLatch computeLatch = new CountDownLatch(1);
+
+        IgniteFuture<Collection<Integer>> fut = 
client.compute().broadcastAsync(() -> {
+            computeLatch.await();
+
+            return 1;
+        });
+
+        try {
+            AtomicReference<ComputeJobView> jobViewHolder = new 
AtomicReference<>();
+            boolean res = waitForCondition(() -> {
+                SystemView<ComputeJobView> jobs = 
grid(0).context().systemView().view(JOBS_VIEW);
+
+                if (jobs.size() >= 1) {
+                    assertEquals(1, jobs.size());
+                    jobViewHolder.set(jobs.iterator().next());
+                    return true;
+                }
+
+                return false;
+            }, TIMEOUT);
+
+            assertTrue(res);
+
+            executeSql(client, "KILL COMPUTE '" + jobViewHolder.get().id() + 
"'");
+
+            assertThrowsWithCause(() -> fut.get(TIMEOUT), 
IgniteException.class);
+        }
+        finally {
+            computeLatch.countDown();
+        }
+    }
+
+    /** */
+    @Test
+    public void testCancelTx() {
+        IgniteCache<Object, Object> cache = client.cache(DEFAULT_CACHE_NAME);
+
+        int testKey = PAGES_CNT * (PAGE_SZ + 1);
+
+        try (Transaction tx = client.transactions().txStart()) {
+            cache.put(testKey, 1);
+
+            executeSql(client, "KILL TRANSACTION '" + tx.xid() + "'");
+
+            assertThrowsWithCause(tx::commit, IgniteException.class);
+        }
+
+        assertNull(cache.get(testKey));
+    }
+
+    /** @throws Exception If failed. */
+    @Test
+    public void testCancelService() throws Exception {
+        String serviceName = "MY_SERVICE";
+
+        ServiceConfiguration scfg = new ServiceConfiguration();
+        scfg.setName(serviceName);
+        scfg.setMaxPerNodeCount(1);
+        scfg.setNodeFilter(grid(0).cluster().predicate());
+        scfg.setService(new TestServiceImpl());
+
+        client.services().deploy(scfg);
+
+        TestService svc = client.services().serviceProxy(serviceName, 
TestService.class, true);
+        assertNotNull(svc);
+
+        executeSql(client, "KILL SERVICE '" + serviceName + "'");
+
+        boolean res = waitForCondition(() -> 
grid(0).context().systemView().view(SVCS_VIEW).size() == 0, TIMEOUT);
+        assertTrue(res);
+    }
+
+    /** @throws Exception If failed. */
+    @Test
+    public void testCancelContinuousQuery() throws Exception {
+        IgniteCache<Object, Object> cache = client.cache(DEFAULT_CACHE_NAME);
+
+        ContinuousQuery<Integer, Integer> cq = new ContinuousQuery<>();
+
+        AtomicInteger cntr = new AtomicInteger();
+
+        cq.setInitialQuery(new ScanQuery<>());
+        cq.setTimeInterval(1_000L);
+        cq.setPageSize(PAGE_SZ);
+        cq.setLocalListener(events -> {
+            for (CacheEntryEvent<? extends Integer, ? extends Integer> e : 
events) {
+                assertNotNull(e);
+
+                cntr.incrementAndGet();
+            }
+        });
+
+        cache.query(cq);
+
+        for (int i = 0; i < PAGE_SZ * PAGE_SZ; i++)
+            cache.put(i, i);
+
+        boolean res = waitForCondition(() -> cntr.get() == PAGE_SZ * PAGE_SZ, 
TIMEOUT);
+        assertTrue(res);
+
+        SystemView<ContinuousQueryView> contQueries = 
grid(0).context().systemView().view(CQ_SYS_VIEW);
+        assertEquals(1, contQueries.size());
+
+        ContinuousQueryView cqView = contQueries.iterator().next();
+        UUID nodeId = cqView.nodeId();
+        UUID routineId = cqView.routineId();
+
+        executeSql(client, "KILL CONTINUOUS '" + nodeId + "' '" + routineId + 
"'");
+
+        long cnt = cntr.get();
+
+        for (int i = 0; i < PAGE_SZ * PAGE_SZ; i++)
+            cache.put(i, i);
+
+        res = waitForCondition(() -> contQueries.size() == 0, TIMEOUT);
+        assertTrue(res);
+        assertEquals(cnt, cntr.get());
+    }
+
+    /** */
+    @Test
+    public void testCancelUnknownScanQuery() {
+        executeSql(client, "KILL SCAN '" + client.localNode().id() + "' 
'unknown' 1");
+    }
+
+    /** */
+    @Test
+    public void testCancelUnknownComputeTask() {
+        executeSql(client, "KILL COMPUTE '" + IgniteUuid.randomUuid() + "'");
+    }
+
+    /** */
+    @Test
+    public void testCancelUnknownService() {
+        executeSql(client, "KILL SERVICE 'unknown'");
+    }
+
+    /** */
+    @Test
+    public void testCancelUnknownTx() {
+        executeSql(client, "KILL TRANSACTION '" + IgniteUuid.randomUuid() + 
"'");
+    }
+
+    /** */
+    @Test
+    public void testCancelUnknownContinuousQuery() {
+        executeSql(client, "KILL CONTINUOUS '" + grid(0).localNode().id() + "' 
'" + UUID.randomUUID() + "'");
+    }
+
+    private static List<Ignite> servers() {
+        return G.allGrids().stream().filter(g -> 
!g.cluster().localNode().isClient()).collect(Collectors.toList());
+    }
+
+    /** */
+    public interface TestService extends Service {
+        /** */
+        public void doTheJob();
+    }
+
+    /** */
+    public static class TestServiceImpl implements TestService {
+        /** {@inheritDoc} */
+        @Override public void cancel(ServiceContext ctx) {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void init(ServiceContext ctx) {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void execute(ServiceContext ctx) {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void doTheJob() {
+            // No-op.
+        }
+    }
+}
diff --git 
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlDdlParserTest.java
 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlDdlParserTest.java
index bbb2fdb..97b8b7e 100644
--- 
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlDdlParserTest.java
+++ 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/sql/SqlDdlParserTest.java
@@ -18,6 +18,7 @@ package 
org.apache.ignite.internal.processors.query.calcite.sql;
 
 import java.util.List;
 import java.util.Objects;
+import java.util.UUID;
 import java.util.function.Predicate;
 
 import com.google.common.collect.ImmutableList;
@@ -32,6 +33,12 @@ import org.apache.calcite.sql.ddl.SqlKeyConstraint;
 import org.apache.calcite.sql.parser.SqlParseException;
 import org.apache.calcite.sql.parser.SqlParser;
 import org.apache.calcite.sql.validate.SqlValidatorException;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillComputeTask;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillContinuousQuery;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillScanQuery;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillService;
+import 
org.apache.ignite.internal.processors.query.calcite.sql.kill.IgniteSqlKillTransaction;
+import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.hamcrest.CustomMatcher;
@@ -574,6 +581,102 @@ public class SqlDdlParserTest extends 
GridCommonAbstractTest {
         assertParserThrows("drop user test with password 'asd'", 
SqlParseException.class);
     }
 
+    /**
+     * Test kill scan query parsing.
+     */
+    @Test
+    public void killScan() throws Exception {
+        IgniteSqlKill killScan;
+
+        UUID nodeId = UUID.randomUUID();
+        killScan = parse("kill scan '" + nodeId + "' 'cache-name' 100500");
+
+        assertTrue(killScan instanceof IgniteSqlKillScanQuery);
+        assertEquals("cache-name", 
stringValue(((IgniteSqlKillScanQuery)killScan).cacheName()));
+        assertEquals(nodeId.toString(), 
stringValue(((IgniteSqlKillScanQuery)killScan).nodeId()));
+        assertEquals(100500L, 
((IgniteSqlKillScanQuery)killScan).queryId().longValue(true));
+
+        assertParserThrows("kill scan", SqlParseException.class);
+        assertParserThrows("kill scan '1234' 'test' 10", 
SqlParseException.class);
+        assertParserThrows("kill scan '" + UUID.randomUUID() + "' 'test'", 
SqlParseException.class);
+        assertParserThrows("kill scan '" + UUID.randomUUID() + "' 'test' 1.0", 
SqlParseException.class);
+    }
+
+    /**
+     * Test kill service query parsing.
+     */
+    @Test
+    public void killService() throws Exception {
+        IgniteSqlKill killService;
+
+        killService = parse("kill service 'my-service'");
+        assertTrue(killService instanceof IgniteSqlKillService);
+        assertEquals("my-service", 
stringValue(((IgniteSqlKillService)killService).serviceName()));
+
+        assertParserThrows("kill service 'my-service' 'test'", 
SqlParseException.class);
+        assertParserThrows("kill service 10000", SqlParseException.class);
+        assertParserThrows("kill service", SqlParseException.class);
+    }
+
+    /**
+     * Test kill transaction query parsing.
+     */
+    @Test
+    public void killTransaction() throws Exception {
+        IgniteSqlKill killTx;
+
+        String txId = IgniteUuid.randomUuid().toString();
+        killTx = parse("kill transaction '" + txId + "'");
+        assertTrue(killTx instanceof IgniteSqlKillTransaction);
+        assertEquals(txId, 
stringValue(((IgniteSqlKillTransaction)killTx).xid()));
+
+        assertParserThrows("kill transaction '1233415' '1'", 
SqlParseException.class);
+        assertParserThrows("kill transaction 10000", SqlParseException.class);
+        assertParserThrows("kill transaction", SqlParseException.class);
+    }
+
+    /**
+     * Test kill compute task query parsing.
+     */
+    @Test
+    public void killComputeTask() throws Exception {
+        IgniteSqlKill killTask;
+
+        IgniteUuid sesId = IgniteUuid.randomUuid();
+        killTask = parse("kill compute '" + sesId + "'");
+        assertTrue(killTask instanceof IgniteSqlKillComputeTask);
+        assertEquals(sesId.toString(), 
stringValue(((IgniteSqlKillComputeTask)killTask).sessionId()));
+
+        assertParserThrows("kill compute '1233415'", SqlParseException.class);
+        assertParserThrows("kill compute 10000", SqlParseException.class);
+        assertParserThrows("kill compute", SqlParseException.class);
+    }
+
+    /**
+     * Test kill continuous query parsing.
+     */
+    @Test
+    public void killContinuousQuery() throws Exception {
+        IgniteSqlKill killTask;
+
+        UUID routineId = UUID.randomUUID();
+        UUID nodeId = UUID.randomUUID();
+
+        killTask = parse("kill continuous '" + nodeId + "' '" + routineId + 
"'");
+        assertTrue(killTask instanceof IgniteSqlKillContinuousQuery);
+        assertEquals(nodeId.toString(), 
stringValue(((IgniteSqlKillContinuousQuery)killTask).nodeId()));
+        assertEquals(routineId.toString(), 
stringValue(((IgniteSqlKillContinuousQuery)killTask).routineId()));
+
+        assertParserThrows("kill continuous '1233415'", 
SqlParseException.class);
+        assertParserThrows("kill continuous '1233415' 1000", 
SqlParseException.class);
+        assertParserThrows("kill continuous '123' '123'", 
SqlParseException.class);
+        assertParserThrows("kill continuous", SqlParseException.class);
+    }
+
+    private static String stringValue(SqlLiteral literal) {
+        return literal != null ? literal.getValueAs(String.class) : null;
+    }
+
     /** */
     private void assertParserThrows(String sql, Class<? extends Exception> 
cls) {
         assertParserThrows(sql, cls, "");
diff --git 
a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java
 
b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java
index ba0abda..253f06d 100644
--- 
a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java
+++ 
b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java
@@ -31,6 +31,7 @@ import 
org.apache.ignite.internal.processors.query.calcite.integration.CalciteEr
 import 
org.apache.ignite.internal.processors.query.calcite.integration.IndexDdlIntegrationTest;
 import 
org.apache.ignite.internal.processors.query.calcite.integration.IndexSpoolIntegrationTest;
 import 
org.apache.ignite.internal.processors.query.calcite.integration.JoinIntegrationTest;
+import 
org.apache.ignite.internal.processors.query.calcite.integration.KillCommandDdlIntegrationTest;
 import 
org.apache.ignite.internal.processors.query.calcite.integration.MetadataIntegrationTest;
 import 
org.apache.ignite.internal.processors.query.calcite.integration.ServerStatisticsIntegrationTest;
 import 
org.apache.ignite.internal.processors.query.calcite.integration.SetOpIntegrationTest;
@@ -66,6 +67,7 @@ import org.junit.runners.Suite;
     TableDdlIntegrationTest.class,
     IndexDdlIntegrationTest.class,
     UserDdlIntegrationTest.class,
+    KillCommandDdlIntegrationTest.class,
     FunctionsTest.class,
     TableDmlIntegrationTest.class,
     DataTypesTest.class,
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillComputeTaskCommand.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillComputeTaskCommand.java
index 9d6d98c..66b42a2 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillComputeTaskCommand.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillComputeTaskCommand.java
@@ -36,6 +36,20 @@ public class SqlKillComputeTaskCommand implements SqlCommand 
{
     /** Session id. */
     private IgniteUuid sesId;
 
+    /**
+     * Default constructor.
+     */
+    public SqlKillComputeTaskCommand() {
+        // No-op.
+    }
+
+    /**
+     * @param sesId Session id.
+     */
+    public SqlKillComputeTaskCommand(IgniteUuid sesId) {
+        this.sesId = sesId;
+    }
+
     /** {@inheritDoc} */
     @Override public SqlCommand parse(SqlLexer lex) {
         if (lex.shift()) {
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillContinuousQueryCommand.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillContinuousQueryCommand.java
index 4f85045..55f2159 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillContinuousQueryCommand.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillContinuousQueryCommand.java
@@ -42,6 +42,23 @@ public class SqlKillContinuousQueryCommand implements 
SqlCommand {
     /** Routine id. */
     private UUID routineId;
 
+    /**
+     * Default constructor.
+     */
+    public SqlKillContinuousQueryCommand() {
+        // No-op.
+    }
+
+    /**
+     *
+     * @param originNodeId Origin node id.
+     * @param routineId Routine id.
+     */
+    public SqlKillContinuousQueryCommand(UUID originNodeId, UUID routineId) {
+        this.originNodeId = originNodeId;
+        this.routineId = routineId;
+    }
+
     /** {@inheritDoc} */
     @Override public SqlCommand parse(SqlLexer lex) {
         if (lex.shift() && lex.tokenType() == SqlLexerTokenType.STRING) {
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillScanQueryCommand.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillScanQueryCommand.java
index 4e96212..22cd5be 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillScanQueryCommand.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillScanQueryCommand.java
@@ -46,6 +46,24 @@ public class SqlKillScanQueryCommand implements SqlCommand {
     /** Query id. */
     private long qryId;
 
+    /**
+     * Default constructor.
+     */
+    public SqlKillScanQueryCommand() {
+        // No-op.
+    }
+
+    /**
+     * @param originNodeId Originated node.
+     * @param cacheName Cache name.
+     * @param qryId Query id.
+     */
+    public SqlKillScanQueryCommand(UUID originNodeId, String cacheName, long 
qryId) {
+        this.originNodeId = originNodeId;
+        this.cacheName = cacheName;
+        this.qryId = qryId;
+    }
+
     /** {@inheritDoc} */
     @Override public SqlCommand parse(SqlLexer lex) {
         if (lex.shift()) {
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillServiceCommand.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillServiceCommand.java
index 2f22594..e7d26e2 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillServiceCommand.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillServiceCommand.java
@@ -33,6 +33,20 @@ public class SqlKillServiceCommand implements SqlCommand {
     /** Service name. */
     private String name;
 
+    /**
+     * Default constructor.
+     */
+    public SqlKillServiceCommand() {
+        // No-op.
+    }
+
+    /**
+     * @param name Service name.
+     */
+    public SqlKillServiceCommand(String name) {
+        this.name = name;
+    }
+
     /** {@inheritDoc} */
     @Override public SqlCommand parse(SqlLexer lex) {
         if (lex.shift()) {
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillTransactionCommand.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillTransactionCommand.java
index 5135c51..430e29c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillTransactionCommand.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillTransactionCommand.java
@@ -33,6 +33,20 @@ public class SqlKillTransactionCommand implements SqlCommand 
{
     /** Transaction xid. */
     private String xid;
 
+    /**
+     * Default constructor.
+     */
+    public SqlKillTransactionCommand() {
+        // No-op.
+    }
+
+    /**
+     * @param xid Transaction id.
+     */
+    public SqlKillTransactionCommand(String xid) {
+        this.xid = xid;
+    }
+
     /** {@inheritDoc} */
     @Override public SqlCommand parse(SqlLexer lex) {
         if (lex.shift()) {

Reply via email to