Hive : How to Kill a Running Query in Apache Hive

Hive @

There may be times when a running query needs to be terminated due to excessive resource usage, incorrect syntax, or a more urgent task. This article will guide you through the process of killing a running Hive query and confirm that it is not running in the background.


Before starting, make sure you have:

  • Basic knowledge of SQL and the Hadoop ecosystem
  • Access to a Hive instance
  • Necessary permissions to manage queries

Killing a Hive Query

Step 1: Identify the Query to be Killed

You must first identify the query you want to terminate. Hive assigns a unique query ID to each query at the time of its initiation. You can use the Hive Web Interface, HiveQL, or Hive logs, as described in the previous section, to identify the long-running query and its query ID.

Step 2: Kill the Query

Once you have the query ID, you can use it to kill the query. However, Hive does not provide an explicit command to kill a running query. But, in a Hadoop ecosystem, YARN (Yet Another Resource Negotiator) is responsible for resource management, and it does provide a command to kill running applications. Since every Hive query is a YARN application, you can kill a Hive query by killing the corresponding YARN application.

To kill a running query in Hive, follow these steps:

1. Identify the YARN Application ID: Hive queries are submitted as YARN applications, and each query has an associated application ID. You can find this application ID in the Hive logs or Hive command line output.

2. Kill the Application: Use the yarn application -kill <Application ID> command in the Hadoop command line to kill the running application. Replace <Application ID> with the actual application ID of the query you want to kill.

Here’s an example:

yarn application -kill application_878667335695370_0001

Confirming Query Termination

Step 1: Check in YARN

The first place to check is YARN. After running the kill command, YARN should display a message indicating that the application has been killed successfully.

Step 2: Verify through Hive Web Interface

After killing the query, you can confirm its termination by accessing the Hive Web Interface. The interface should no longer list the query under running queries.

Step 3: Confirm through Hive Query Log

Finally, the Hive query log is another place where you can verify the termination of the query. After a query has been killed, a message should be logged with the details of the query termination.

Hive important pages to refer

  1. Hive
  2. Hive Interview Questions
  3. Hive Official Page
  4. Spark Examples
  5. PySpark Blogs
  6. Bigdata Blogs
  7. Spark Interview Questions
  8. Spark Official Page
Author: user

Leave a Reply