Repository: mindsdb/mindsdb
Pull request: Added Hive Handler #2360
Fixes #2360

## Please describe what changes you made, in as much detail as possible
- I Have added Hive Handler to mindsdb's Repo for DEV contest and it has passed all basic Testing

mindsdb

Problem statement:
Hive (Hive Server2?) as a Datasource
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe.

A user would like to use Hive as a datasource.



### Describe the solution you'd like.

Be able to train ML models in MindsDB from Hive (server2?)

### Describe an alternate solution.

_No response_

### Anything else? (Additional Context)

This is a feature that a potential paid customer would like.

_We use airbyte to sync data between a Postgres database and a Databricks Spark cluster. We then use DBT to transform those tables into useful data products within Databricks._

Hints from issue discussion:
Hi @ZoranPandovski. Can I take this up?
Hey sure @bispaul 
Hi @bispaul, did you start on this?
Hi @ZoranPandovski , I have started but couldn't work much due to my workload. I will try to complete this before the end of this month. Thank You.

Commit message: Added Hive Handler #2360

Patch to review:
diff --git a/mindsdb/integrations/handlers/hive_handler/README.md b/mindsdb/integrations/handlers/hive_handler/README.md
new file mode 100644
index 00000000000..aaaf1fdc515
--- /dev/null
+++ b/mindsdb/integrations/handlers/hive_handler/README.md
@@ -0,0 +1,40 @@
+# Hive Handler
+
+This is the implementation of the  Hive handler for MindsDB.
+
+## Hive
+The Apache Hive ™ data warehouse software facilitates reading, writing, and managing large datasets residing in distributed storage using SQL. Structure can be projected onto data already in storage.
+
+## Implementation
+This handler was implemented using the `pyHive`, a Python library that allows you to use Python code to run SQL commands on Hive.
+
+The required arguments to establish a connection are,
+* `user`: username asscociated with database
+* `password`: password to authenticate your access
+* `host`: host to server IP Address or hostname
+* `port`: port through which TCPIP connection is to be made
+* `database`: Database name to be connected
+* `auth`: Defaults to CUSTOM in case not provided. Check for other options in [https://pypi.org/project/PyHive/](https://pypi.org/project/PyHive/)
+
+
+## Usage
+In order to make use of this handler and connect to Hive in MindsDB, the following syntax can be used,
+~~~~sql
+CREATE DATABASE hive_datasource
+WITH
+engine='hive',
+parameters={
+    "user": "demo_user",
+    "password": "demo_password",
+    "host": "127.0.0.1",
+    "port": "10000",
+    "database": "default"
+};
+~~~~
+
+Now, you can use this established connection to query your database as follows,
+~~~~sql
+SELECT * FROM hive_datasource.test_hdb;
+~~~~
+
+NOTE : To install `pyHive` the following linux packages are required `libsasl2-dev sasl2-bin libsasl2-2 libsasl2-dev libsasl2-modules libsasl2-modules-gssapi-mit`
diff --git a/mindsdb/integrations/handlers/hive_handler/__about__.py b/mindsdb/integrations/handlers/hive_handler/__about__.py
new file mode 100644
index 00000000000..fd7180827b2
--- /dev/null
+++ b/mindsdb/integrations/handlers/hive_handler/__about__.py
@@ -0,0 +1,9 @@
+__title__ = 'MindsDB Hive handler'
+__package_name__ = 'mindsdb_hive_handler'
+__version__ = '0.0.1'
+__description__ = "MindsDB handler for Hive2"
+__author__ = 'Biswadip Paul'
+__github__ = 'https://github.com/mindsdb/mindsdb'
+__pypi__ = 'https://pypi.org/project/mindsdb/'
+__license__ = 'GPL-3.0'
+__copyright__ = 'Copyright 2022- mindsdb'
diff --git a/mindsdb/integrations/handlers/hive_handler/__init__.py b/mindsdb/integrations/handlers/hive_handler/__init__.py
new file mode 100644
index 00000000000..3df1b403880
--- /dev/null
+++ b/mindsdb/integrations/handlers/hive_handler/__init__.py
@@ -0,0 +1,23 @@
+from mindsdb.integrations.libs.const import HANDLER_TYPE
+
+from .__about__ import __version__ as version, __description__ as description
+try:
+    from .hive_handler import (
+        HiveHandler as Handler,
+        connection_args_example,
+        connection_args
+    )
+    import_error = None
+except Exception as e:
+    Handler = None
+    import_error = e
+
+title = 'Hive'
+name = 'hive'
+type = HANDLER_TYPE.DATA
+icon_path = 'icon.svg'
+
+__all__ = [
+    'Handler', 'version', 'name', 'type', 'title', 'description',
+    'connection_args', 'connection_args_example', 'import_error', 'icon_path'
+]
diff --git a/mindsdb/integrations/handlers/hive_handler/hive_handler.py b/mindsdb/integrations/handlers/hive_handler/hive_handler.py
new file mode 100644
index 00000000000..d8c69344fe8
--- /dev/null
+++ b/mindsdb/integrations/handlers/hive_handler/hive_handler.py
@@ -0,0 +1,191 @@
+from typing import Optional
+from collections import OrderedDict
+import pandas as pd
+from pyhive import (hive, sqlalchemy_hive)
+from sqlalchemy import create_engine
+
+from mindsdb_sql import parse_sql
+from mindsdb_sql.render.sqlalchemy_render import SqlalchemyRender
+from mindsdb_sql.parser.ast.base import ASTNode
+
+from mindsdb.utilities.log import log
+from mindsdb.integrations.libs.base_handler import DatabaseHandler
+from mindsdb.integrations.libs.response import (
+    HandlerStatusResponse as StatusResponse,
+    HandlerResponse as Response,
+    RESPONSE_TYPE
+)
+from mindsdb.integrations.libs.const import HANDLER_CONNECTION_ARG_TYPE as ARG_TYPE
+
+
+class HiveHandler(DatabaseHandler):
+    """
+    This handler handles connection and execution of the Hive SQL statements.
+    """
+
+    name = 'hive'
+
+    def __init__(self, name: str, connection_data: Optional[dict], **kwargs):
+        super().__init__(name)
+        self.parser = parse_sql
+        self.dialect = 'hive'
+
+        self.connection_data = connection_data
+        self.kwargs = kwargs
+
+        self.connection = None
+        self.is_connected = False
+
+    def __del__(self):
+        if self.is_connected is True:
+            self.disconnect()
+
+    def connect(self):
+        if self.is_connected is True:
+            return self.connection
+
+        config = {
+            'host': self.connection_data.get('host'),
+            'port': self.connection_data.get('port'),
+            'auth': self.connection_data.get('auth', 'CUSTOM'),
+            'username': self.connection_data.get('user'),
+            'password': self.connection_data.get('password'),
+            'database': self.connection_data.get('database')
+        }
+
+        connection = hive.Connection(**config)
+        self.is_connected = True
+        self.connection = connection
+        return self.connection
+
+    def disconnect(self):
+        if self.is_connected is False:
+            return
+        self.connection.close()
+        self.is_connected = False
+        return
+
+    def check_connection(self) -> StatusResponse:
+        """
+        Check the connection of the Hive database
+        :return: success status and error message if error occurs
+        """
+
+        response = StatusResponse(False)
+        need_to_close = self.is_connected is False
+
+        try:
+            self.connect()
+            response.success = True
+        except Exception as e:
+            log.error(f'Error connecting to Hive {self.connection_data["database"]}, {e}!')
+            response.error_message = str(e)
+
+        if response.success is True and need_to_close:
+            self.disconnect()
+        if response.success is False and self.is_connected is True:
+            self.is_connected = False
+
+        return response
+
+    def native_query(self, query: str) -> Response:
+        """
+        Receive SQL query and runs it
+        :param query: The SQL query to run in Hive
+        :return: returns the records from the current recordset
+        """
+
+        need_to_close = self.is_connected is False
+
+        connection = self.connect()
+        with connection.cursor() as cur:
+            try:
+                cur.execute(query)
+                result = cur.fetchall()
+                if result:
+                    response = Response(
+                        RESPONSE_TYPE.TABLE,
+                        pd.DataFrame(
+                            result,
+                            columns=[x[0].split('.')[1] for x in cur.description]
+                        )
+                    )
+                else:
+                    response = Response(RESPONSE_TYPE.OK)
+                connection.commit()
+            except Exception as e:
+                log.error(f'Error running query: {query} on {self.connection_data["database"]}!')
+                response = Response(
+                    RESPONSE_TYPE.ERROR,
+                    error_message=str(e)
+                )
+                connection.rollback()
+
+        if need_to_close is True:
+            self.disconnect()
+
+        return response
+
+    def query(self, query: ASTNode) -> Response:
+        """
+        Retrieve the data from the SQL statement.
+        """
+        renderer = SqlalchemyRender(sqlalchemy_hive.HiveDialect)
+        query_str = renderer.get_string(query, with_failback=True)
+        return self.native_query(query_str)
+        # return self.native_query(query.to_string())
+
+    def get_tables(self) -> Response:
+        """
+        Get a list with all of the tables in Hive
+        """
+        q = "SHOW TABLES"
+        result = self.native_query(q)
+        df = result.data_frame
+        result.data_frame = df.rename(columns={df.columns[0]: 'table_name'})
+        return result
+
+    def get_columns(self, table_name) -> Response:
+        """
+        Show details about the table
+        """
+        q = f"DESCRIBE {table_name}"
+        result = self.native_query(q)
+        return result
+
+
+connection_args = OrderedDict(
+    user={
+        'type': ARG_TYPE.STR,
+        'description': 'The user name used to authenticate with the Hive server.'
+    },
+    password={
+        'type': ARG_TYPE.STR,
+        'description': 'The password to authenticate the user with the Hive server.'
+    },
+    database={
+        'type': ARG_TYPE.STR,
+        'description': 'The database name to use when connecting with the Hive server.'
+    },
+    host={
+        'type': ARG_TYPE.STR,
+        'description': 'The host name or IP address of the Hive server. NOTE: use \'127.0.0.1\' instead of \'localhost\' to connect to local server.'
+    },
+    port={
+        'type': ARG_TYPE.INT,
+        'description': 'The TCP/IP port of the Hive server. Must be an integer.'
+    },
+    auth={
+        'type': ARG_TYPE.STR,
+        'description': 'The Auth type of the Hive server.'
+    }
+)
+
+connection_args_example = OrderedDict(
+    host='127.0.0.1',
+    port='10000',
+    auth='CUSTOM',
+    user='root',
+    password='password',
+    database='database'
+)
diff --git a/mindsdb/integrations/handlers/hive_handler/icon.svg b/mindsdb/integrations/handlers/hive_handler/icon.svg
new file mode 100644
index 00000000000..031ad38977a
--- /dev/null
+++ b/mindsdb/integrations/handlers/hive_handler/icon.svg
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="900" width="1e3" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="0 0 1000 900">
+ <g stroke="#fdee21" stroke-width="5.1286" transform="translate(-.53268 66.8)" fill-rule="evenodd">
+  <path d="m597.33 637.79v192.85h47.346v-88.632l9.7674 0.18273v88.45h47.881v-192.85h-47.881v71.552h-9.7674v-71.552z"/>
+  <path d="m761.25 637.79h-46.116v192.85h46.116z"/>
+  <path d="m768.8 637.79 36.429 192.85h54.984l36.429-192.85h-48.951l-12.067 82.517c-1.0055 3.1605-4.402 3.1605-5.0089 0l-12.06-82.52z"/>
+  <path d="m997.97 637.79h-91.538v192.85h91.538v-50.569l-50.898-0.43357 0.00017-21.679h24.248v-50.204h-24.248l-0.00017-19.397h50.898z"/>
+ </g>
+ <g transform="translate(-.53268 66.8)">
+  <path d="m503.66 52.952c-7.71-21.115-272.92-124.22-276.31-112.9-48.7 12.695-68.52 68.826-102.02 104.38l-74.393-4.261c-32.771 42.142-49.967 85.199-38.258 129.95 42.002 56.906 90.76 105.33 121.15 176.81 2.402 33.692 145.82 3.533 176.56-3.1364-41.992 30.059-78.561 76.651-62.846 210.84 14.346 63.014 24.159 133.37 151.4 204.64 16.75 9.3816 51.407 20.207 72.838 28.098 20.495 9.4012 44.461 13.264 112.07-7.4123 39.124-16.863 81.365-27.022 119.65-43.844l-46.017 2.1595c-63.369 1.3787-112.29 6.1057-127.38-11.6l-58.32-100.68 34-66.04c47.056 4.8263 62.675 42.986 104.15 57.518l48.885-36.215c141.99 83.816 198.48-53.12 214.67-159.77-1.7276-43.392-93.952 13.611-88.362-6.6789 2.1662-46.644-35.854-107.67-60.42-155.22l28.43-110.01c12.9-11.49-59.72-133.86-119.02-149.12-52.03-13.391-130.46 52.492-130.46 52.492z" fill-rule="evenodd" fill="#fdee21"/>
+ </g>
+ <g fill-rule="evenodd">
+  <g fill="#c8c037" transform="translate(-.53268 66.8)">
+   <path d="m736.92 286.75c0.50927 11.816 0.45216 26.187 1.5941 35.15-0.19663 6.8382-5.3227 7.0888-9.5645 8.5212l27.631 10.119c5.4855 9.2313 9.8941 18.463 14.347 27.694 5.1652 22.708 1.3105 23.357-2.1254 25.031-10.027 0.10212-20.025 0.12088-29.358-1.864 4.181 2.2066 5.1006 3.8152 5.543 6.642 0.81556 5.2117-2.5407 12.329-8.0669 19.188 8.1718 4.534 23.071 8.9698 34.14 13.181l12.62-28.093c-5.7151-41.271-23.045-79.309-46.76-115.57z"/>
+   <path d="m788.49 425.18c15.324 6.3872 36.495 4.5146 65.848-10.613 4.3653-3.1043 8.4311-1.2485 0.61937 3.8577-38.499 34.547-56.927 17.265-66.467 6.7552z"/>
+   <path d="m857.28 410.04c4.5523 8.7165 1.7942 15.805 0.26568 23.167-4.7534 37.449-16.423 67.056-39.321 97.994-74.478 119.74-149.67 44.817-209.62-3.9455l-24.798 62.137c-1.3162 5.4464-6.7903 9.688 31.937 26.738l39.452-27.867c150.46 114.48 257.08-160.24 202.08-178.22z"/>
+   <path d="m626.75 517.04c-10.151 0.72442-40.361 10.997-41.706 16.946l13.902-20.712z"/>
+   <path d="m607.01 390.07c1.8598 0 10.788 2.3971 9.8302 1.864-1.3698-0.76256-0.15272 12.519 2.6568 19.439l-10.893 23.7c20.865-24.063 53.858-22.462 84.486-25.564l-14.612-9.0537c2.5384-8.4664-0.45059-15.165-1.8598-22.368z"/>
+   <path d="m658.28 318.71c-22.387 6.8632-43.816 18.075-58.203 41.976 10.976-39.395 13.213-37.899 16.757-39.846 15.351-6.8651 27.922-2.5864 41.446-2.1303z"/>
+  </g>
+  <g fill="#fcf6a0" transform="translate(-.53268 66.8)">
+   <path d="m538.73 780.45c-27.07 29.87-87.47-2.26-137.63-18.64-127.46-81.05-152.36-157.35-154.09-232.2-6.5535-107.22 26.37-169.52 68.014-184.27-27.561 53.129-40.41 148.5-27.631 219.42 10.315 39.455 10.529 106 76.545 141.62 32.327 18.199 23.571 32.368 45.431 49.413 23.955 18.679 90.747 36.437 129.36 24.658z"/>
+   <path d="m579.17 284.94c-45.831-64.991-110.29-89.387-182.98-92.053 14.568-4.7488 29.136-7.2216 43.704-14.246 3.5675-3.7484 2.4012-10.344 1.0627-17.042-69.97-18.27-114.13-40.85-170.03-61.781l150.91 36.215c101.91 3.8724 93.158 29.032 157.34 148.91z"/>
+   <path d="m628.24 253.6c-33.87-48.35-66.72-107.03-111.31-144.35-107.64-48.584-214.12-84.666-338.91-117.5l39.827-51.216c132.42 30.227 256.8 80.808 368.21 164.19 18.849 47.66 31.419 95.383 42.173 148.87z"/>
+   <path d="m696.52 168.16s-18.988-42.599-28.233-58.866c-21.446-23.766-32.29-68.054-76.213-88.922 13.892 3.7515 23.399-0.7183 51.759 24.992l44.669 84.734z"/>
+   <path d="m720.14 241.96c4.3792-36.908 12.695-96.11 3.1517-119.5-26.55-35.624-53.29-72.446-80.04-106.63-4.43-4.123-7.62-9.7186-11.11-14.084 37.61 9.744 76.86 35.894 129.79 139.13z"/>
+  </g>
+  <g transform="translate(-.53268 66.8)">
+   <path d="m562.02 246.32c-14.98-11.79-28.33-53.49-51.03-62.16-21.011-1.7577-28.715-8.3682-56.344-2.7386 10.021-5.0213 19.482-11.446 30.134-14.885 7.2152-1.7032 13.983 0.18382 20.867 1.1334 1.6999-0.80357 2.8139-1.8029 2.3983-3.3133-27.812-17.187-84.866-17.432-123.38-27.243 44.699 1.4962 94.156-0.9815 127.75 9.7912 27.013 23.973 35.788 69.119 49.605 99.415z"/>
+   <path d="m643.93 45.227c6.2011 0.56336 39.574 53.353 41.142 62.137 2.7751 19.202 9.6196 40.728 11.46 60.819-5.4968-19.269-11.486-38.537-18.974-57.806-2.1898-5.3062-7.7241-17.302-23.107-34.269-7.1628-11.959-8.7092-21.359-10.52-30.88z"/>
+   <path d="m757.02 332.75h-14.278l15.781 4.1424z"/>
+   <path d="m659.6 318.49c-14.358-1.7651-29.091-1.9991-43.448 1.1565-5.8522 7.8608-6.2554 15.856-8.813 23.245 17.454-19.236 24.38-20.412 52.261-24.401z"/>
+   <path d="m855.42 417.77c-7.99 6.3771-8.7884 12.379-32.413 19.572-17.228 4.074-26.961-2.8314-35.07-12.116 12.294 3.5217 14.259 12.81 47.225 2.3966z"/>
+   <path d="m783.82 421.76c-5.7504 15.812-11.949 31.791-18.199 46.6-14.883 17.454-8.5402 7.5079-30.819 34.617 7.1285-10.998 16.4-21.566 21.254-33.02 3.4091-7.5422 7.6532-15.543 9.5323-22.244-5.9074-2.95-17.999-3.1834-19.639-2.1247-19.808 11.683-23.382 24.047-35.059 36.086 8.4637-13.53 15.693-28.298 25.505-40.476 1.1181-1.5806 8.3826-1.8863 12.849-2.8189-6.9404-1.1908-19.786-3.6848-20.82-3.572-12.922 3.1053-20.163 14.361-29.756 21.836 6.9939-10.098 13.436-20.612 22.317-29.292 0.8785-1.0208 24.883 1.0822 37.324 6.0466l0.2468 4.9491 7.0633 2.8512 5.3136-13.314z"/>
+   <path d="m627.07 517.09c-3.1882-1.0895-31.35-4.7112-31.35-3.8611-10.813 7.6957-12.453 15.059-12.221 21.436 17.989-17.697 17.319-17.747 43.572-17.575z"/>
+   <path d="m605.68 389.81s20.322-2.9626 19.926-1.0652c-1.4722 7.0504 2.4876 24.233 2.9225 21.836l-11.424 9.32c23.926-12.029 49.113-9.6117 74.656-11.45 0 0-21.507-5.9381-20.192-6.1246 4.7977-0.6803-1.2772-22.43-2.9225-22.901 4.0915-1.3847 8.0873-2.4285 12.221-3.4617-30.756-8.0483-48.541-3.3059-75.188 13.847z"/>
+   <path d="m781.56 404.98-4.5166 2.2634c-0.6408-13.231-14.851-12.26-26.834-12.382l-9.8302-2.3966c2.9889 2.7664 12.229 2.5495 8.5018 8.5212-3.1367 1.6765-4.5798 8.87-6.3763 14.912l-5.3136 0.26628c9.3867 3.6684 18.095 6.8836 28.428 11.184l6.1106 0.932 14.612-7.8555z"/>
+  </g>
+  <g fill="#fff" transform="translate(-.53268 66.8)">
+   <path d="m646.86 396.06c-2.2872-4.5248-13.794-3.8824-16.275-0.95484-2.0158 2.3788-0.12514 17.642 2.4595 15.068 3.7368-3.2849 8.6176-4.6588 14.48-4.3938 0.73904-2.82 0.47742-5.8648-0.66421-9.7194z"/>
+   <path d="m757.21 418.8c1.0816-0.79113 3.3689-8.4434 2.6301-10.733-1.5117-5.4032-12.212-4.2659-12.212-4.2659-2.6108 1.5363-4.8989 9.9596-3.9448 12.739 0.45543 2.3526 11.809 3.1025 13.526 2.2595z"/>
+  </g>
+  <g transform="translate(-.53268 66.8)">
+   <path d="m299.64 682.84 6.7596 0.66112c40.071 19.675 106.05 48.847 201.57 33.171l14.988 23.584c-42.067 20.442-87.312 15.738-129.71 17.172z"/>
+   <path d="m242.11 527.3 20.073 84.268c53.74 33.593 145.54 72.07 222.06 68.965l-16.91-38.8c-159.73-33.92-173.24-76.8-225.22-114.44z"/>
+   <path d="m292.06 354.69c9.8106 65.302 22.907 114.81 79.69 156.28 34.804 25.03 69.351 49.954 111.37 70.524 0 0-3.6836 19.171-6.7631 18.829-125.05-13.89-216.6-117.58-227.69-164.94 10.741-36.329 26.149-59.021 43.389-80.693z"/>
+   <path d="m352.17 317.69c16.664 72.376 56.397 145.68 95.889 212.18 14.477 18.369 18.266 26.475 40.579 37.659 30.159 9.5492 51.486 7.1119 73.377 5.6756-5.9982-11.102-11.329-22.706-18.217-33.14-49.018-38.765-26.364-74.06-13.344-96.406-27.256-6.887-63.37-21.525-68.345-40.778-7.9992-62.271-3.9373-82.025 4.0685-114.01-36.909 7.7822-74.309 15.494-114.01 28.82z"/>
+   <path style="color-rendering:auto;text-decoration-color:#000000;color:#000000;isolation:auto;mix-blend-mode:normal;shape-rendering:auto;solid-color:#000000;block-progression:tb;text-decoration-line:none;image-rendering:auto;white-space:normal;text-indent:0;text-transform:none;text-decoration-style:solid" d="m216.77-66.742c-12.131 7.9248-23.818 19.256-36.391 32.135-20.843 21.575-34.699 42.621-55.915 58.224-4.2432 3.6588-16.151 9.5511-31.121 10.425-7.052 0.352-11.646 1.519-24.604-0.108-11.428-6.188-22.285-2.164-32.881 10.51-11.619 16.709-26.334 48.437-32.453 68.41-12.611 50.937 19.541 92.905 50.374 125.25 27.429 26.796 43.243 43.542 54.505 68.107 8.527 15.933 14.844 37.799 21.683 53.13 2.4661 4.8605 1.9534 4.8352 8.5913 6.3 14.333 3.0588 34.215 3.0828 51.915 4.6041 7.6583 0.10691 18.175-0.17813 28.14-1.2168 13.731-2.5928 29.863-5.1333 43.384-9.8098 13.213-3.2535 24.985-7.7592 35.597-11.907-1.3686 4.6442-11.478 9.1153-15.268 15.002-35.97 51.49-45.823 97.308-39.561 169.6 3.5425 32.042 10.896 58.605 21.992 88.997 5.0775 13.908 15.882 35.934 26.236 50.565 30.79 43.506 99.672 99.374 195.56 120.88 16.729 2.2866 35.715 1.067 53.571-3.6882 47.326-14.346 143.78-48.275 143.78-48.275s-85.619 7.0828-124.83 3.2058c-9.0778-1.4195-19.081-1.9011-25.405-8.0872-1.0608-1.3694-4.9144-9.1318-2.4258-9.2015 3.3952-0.095 13.142-4.14 28.191-5.4821-32.129-3.4591-31.671-3.418-34.016-9.2706-3.6471-9.0847-9.2292-21.502-14.977-32.367 14.118 1.1911 45.376 2.9455 55.984-8.0025 0 0-18.497 2.1356-34.843 0.2184-5.5072-0.64595-14.891-3.9946-17.71-5.0297-7.3383-2.858-13.38-3.7456-14.788-5.6091-2.5483-6.4856-4.2751-8.6672-7.3506-17.356-4.1659-11.504-4.4964-24.337-5.2895-36.083 10.693 13.18 24.318 24.275 42.356 29.941 0.23141-0.48776 23.4 10.072 40.226 4.642l3.4886-1.1254c0 0.31134-11.148 0.9767-15.237-1.0474-34.219-14.545-39.37-27.276-44.895-33.599l-14.777-22.133c4.4943-8.9608 7.0351-9.3013 12.989-9.3842 18.011 2.0006 25.848 3.5399 36.807 0.89587 7.4053 15.24 9.4062 30.571 26.265 41.662 56.166 16.672 68.369-4.951 81.973-24.057 40.412 29.658 106.2 38.803 151.89 0.51478 58.086-67.212 76.476-173.17 71.325-179.22-7.2544-12.307-16.772-24.999-24.945-23.245-29.13 7.952-39.871 22.73-68.735 19.359 3.4377-0.19431 9.2187-0.28734 9.2628-0.61508 2.2238-24.441-0.17883-36.267-1.2518-38.297-8.759-19.317-20.261-39.646-28.278-54.881-2.0668-3.1607-8.1367-27.165-18.308-36.648-4.3623-3.7245-15.039-13.546-15.039-13.546l-0.90484 10.439s4.1739 0.63032 5.7624 7.0973c6.0222 24.517 36.687 82.485 38.938 85.263 10.868 17.545 1.1045 39.401 9.3673 51.663 0.7938 1.5578 16.857-0.1365 29.307 0.62845 20.473-4.4034 19.609-13.426 37.294-14.782 11.913-0.91347 13.108 21.46 12.951 23.196-2.22 24.704-9.735 53.427-21.236 79.658-23.912 46.069-50.691 87.446-88.67 93.216-46.326 8.0952-70.399-12.158-95.512-25.055l-9.6068 8.1934c-32.637 32.501-71.389 29.614-87.239-12.851-7.8901-16.473-18.172-26.569-26.976-40.7l-46.688 33.627c-3.8865 7.9708-8.6652 20.54-14.47 34.58-4.0357 9.761-7.4199 26.525-7.1995 40.456-5.9847 10.195 20.729 51.542 37.609 76.692 4.9811 7.4212 14.279 20.385 14.59 21.193 3.3476 8.6831 10.679 16.349 11.124 17.284 31.337 40.872-39.531 31.46-54.167 28.991-28.876-4.601-57.121-16.663-83.67-32.792-1.5406-0.93601-3.0757-1.8853-4.6047-2.848-31.551-19.866-60.581-45.283-85.264-70.423-14.718-16.666-28.732-50.827-39.083-75.045-15.513-58.226-37.776-159.15 22.532-235.63 3.8228-4.3717 7.9478-11.65 11.46-13.09 17.918-12.119 37.375-20.379 58.298-24.966l-2.1122-13.563c-10.449 2.3741-45.633 15.243-55.581 20.629-22.623 6.5582-41.388 13.406-70.22 20.625-9.3724 1.1468-18.592 1.1674-27.579-0.0535-20.741-2.8178-56.094-0.3007-58.349-2.3956-14.044-19.585-17.889-54.676-30.703-73.456l-0.1512-0.1872-0.16231-0.17827c-7.47-10.04-16.177-18.23-24.752-26.75-30.708-30.51-56.991-60.01-64.348-91.27-1.85-9.23-6.614-18.79-4.082-46.1l0.04669-0.1337 0.04447-0.13371c7.388-25.513 19.407-46.31 39.806-67.153 21.228 0.34267 42.24 0.809 58.607 3.9355 7.5089 1.2562 23.124 3.2959 39.252 9.304 40.822 15.207 94.76 40.209 94.76 40.209-40.488-22.236-85.761-51.115-114.35-56.943-4.2536-0.60217-6.8679-2.5426-8.1311-5.93 42.999-25.264 50.865-55.009 79.147-81.686 12.925-5.6262 17.965-8.4984 28.947-9.6917 101.57 16.06 165.51 56.515 216.09 83.566 20.529 11.164 39.191 19.606 57.015 29.773 15.624 5.1391 62.771 40.734 76.569 59.925 14.017 29.595 24.251 61.563 33.585 92.411 6.6931 31.375 12.564 44.102 12.564 44.102s-5.6883-26.243-4.7403-30.958c5.8976 2.2038 19.841 6.5574 25.621 5.881 0 0-25.818-13.346-29.201-25.141-10.856-37.847-21.744-96.765-24.68-99.837-8.274-10.411-42.777-36.816-63.941-49.03-8.006-4.6205-12.333-7.4865-12.671-9.5179 6.761-6.83 15.111-15.865 22.598-21.606 7.1766-5.5031 13.711-11.709 23.713-15.423 43.963-19.8 69.101 7.6176 75.066 2.0656 0 0-9.458-10.841-5.257-9.0564 4.3021 2.3303 18.323 5.0784 19.862 6.5094 16.023 12.534 57.913 58.344 83.161 106.68 6.0639 11.84 8.5288 19.636 5.7164 33.893-2.8199 14.27-5.0017 22.117-8.0777 31.647-2.7784 6.371-18.498 49.988-18.437 55.848-3.1666 23.932 10.264 53.893 10.264 53.893 0.12703-8.1326-0.5003-12.466 0.23677-18.282l0.90404-10.393s-0.573-2.7644-0.46902-3.86c0.6821-7.1867 2.445-13.229 2.9625-17.345 5.0476-31.255 13.822-53.755 23.775-81.182 2.9578-6.9216 6.8277-10.771 6.6303-16.041 0.16274-9.3518-8.2048-21.904-14.252-34.163-6.1-12.39-13.39-26.202-22.96-40.76-21.82-31.376-40.42-55.925-74.48-71.289-9.53-4.1821-47.03-8.2709-59.98-5.8413-15.71 3.2729-29.22 6.5004-39.99 13.398-16.95 10.854-30.27 27.659-45.89 37.561-34.56-17.282-51.24-30.216-54.35-31.999-20.54-11.006-45.2-23.778-71.73-35.89-12.72-11.862-91.71-40.233-164.04-45.892zm442.08 644.59c-21.3-16.65-39.23-33.79-51.05-51.44-3.8582 20.758-17.864 35.542-28.688 50.083-2.1546 3.4104-3.7078 8.0604 6.9022 22.879 2.8598 3.948 13.207 4.6227 20.192 4.2606-7.1065-5.3719-17.918-11.053-19.66-15.977 12.501 8.5109 24.076 10.957 34.538 9.5863 2.3903-0.26867 5.36-2.8037 7.6553-6.7058 4.6637-10.02 8.3155-12.433 12.005-15.13l8.5018 10.651z" stroke="#000" stroke-width=".11397"/>
+  </g>
+ </g>
+</svg>
diff --git a/mindsdb/integrations/handlers/hive_handler/requirements.txt b/mindsdb/integrations/handlers/hive_handler/requirements.txt
new file mode 100644
index 00000000000..308c31661c1
--- /dev/null
+++ b/mindsdb/integrations/handlers/hive_handler/requirements.txt
@@ -0,0 +1,4 @@
+sasl
+thrift
+thrift-sasl
+pyHive
\ No newline at end of file
diff --git a/mindsdb/integrations/handlers/hive_handler/tests/__init__.py b/mindsdb/integrations/handlers/hive_handler/tests/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/mindsdb/integrations/handlers/hive_handler/tests/test_hive_handler.py b/mindsdb/integrations/handlers/hive_handler/tests/test_hive_handler.py
new file mode 100644
index 00000000000..443b5603ff6
--- /dev/null
+++ b/mindsdb/integrations/handlers/hive_handler/tests/test_hive_handler.py
@@ -0,0 +1,53 @@
+import unittest
+
+from mindsdb.integrations.handlers.hive_handler.hive_handler import HiveHandler
+from mindsdb.api.mysql.mysql_proxy.libs.constants.response_type import RESPONSE_TYPE
+
+
+class HiveHandlerTest(unittest.TestCase):
+    @classmethod
+    def setUpClass(cls):
+        cls.kwargs = {
+            "host": "localhost",
+            "port": "10000",
+            "user": "admin",
+            "password": "password",
+            "database": "default",
+            "auth": "CUSTOM"
+        }
+        cls.handler = HiveHandler('test_hive_handler', **cls.kwargs)
+
+    def test_0_connect(self):
+        self.handler.check_connection()
+
+    def test_1_native_query_show_dbs(self):
+        dbs = self.handler.native_query("SHOW DATABASES;")
+        assert dbs['type'] is not RESPONSE_TYPE.ERROR
+
+    def test_2_get_tables(self):
+        tbls = self.handler.get_tables()
+        assert tbls['type'] is not RESPONSE_TYPE.ERROR
+
+    def test_3_get_views(self):
+        views = self.handler.get_views()
+        assert views['type'] is not RESPONSE_TYPE.ERROR
+
+    def test_5_drop_table(self):
+        res = self.handler.native_query("DROP TABLE IF EXISTS test_hdb")
+        assert res['type'] is not RESPONSE_TYPE.ERROR
+
+    def test_4_create_table(self):
+        res = self.handler.native_query("CREATE TABLE IF NOT EXISTS test_hdb (test_col INT)")
+        assert res['type'] is not RESPONSE_TYPE.ERROR
+
+    def test_6_describe_table(self):
+        described = self.handler.get_columns("test_hdb")
+        assert described['type'] is RESPONSE_TYPE.TABLE
+
+    def test_7_select_query(self):
+        query = "SELECT * FROM test_mdb WHERE foo=238"
+        result = self.handler.query(query)
+        assert result['type'] is RESPONSE_TYPE.TABLE
+
+if __name__ == '__main__':
+    unittest.main()
\ No newline at end of file


Code review comments:
diff_hunk: @@ -0,0 +1,191 @@
+from typing import Optional
+from collections import OrderedDict
+import pandas as pd
+from pyhive import (hive, sqlalchemy_hive)
+from sqlalchemy import create_engine
+
+from mindsdb_sql import parse_sql
+from mindsdb_sql.render.sqlalchemy_render import SqlalchemyRender
+from mindsdb_sql.parser.ast.base import ASTNode
+
+from mindsdb.utilities.log import log
+from mindsdb.integrations.libs.base_handler import DatabaseHandler
+from mindsdb.integrations.libs.response import (
+    HandlerStatusResponse as StatusResponse,
+    HandlerResponse as Response,
+    RESPONSE_TYPE
+)
+from mindsdb.integrations.libs.const import HANDLER_CONNECTION_ARG_TYPE as ARG_TYPE
+
+
+class HiveHandler(DatabaseHandler):
+    """
+    This handler handles connection and execution of the Hive SQL statements.
+    """
+
+    name = 'hive'
+
+    def __init__(self, name: str, connection_data: Optional[dict], **kwargs):
+        super().__init__(name)
+        self.parser = parse_sql
+        self.dialect = 'hive'
+
+        self.connection_data = connection_data
+        self.kwargs = kwargs
+
+        self.connection = None
+        self.is_connected = False
+
+    def __del__(self):
+        if self.is_connected is True:
+            self.disconnect()
+
+    def connect(self):
+        if self.is_connected is True:
+            return self.connection
+
+        config = {
+            'host': self.connection_data.get('host'),
+            'port': self.connection_data.get('port'),
+            'auth': self.connection_data.get('auth', 'CUSTOM'),
+            'username': self.connection_data.get('user'),
+            'password': self.connection_data.get('password'),
+            'database': self.connection_data.get('database')
+        }
+
+        connection = hive.Connection(**config)
+        self.is_connected = True
+        self.connection = connection
+        return self.connection
+
+    def disconnect(self):
+        if self.is_connected is False:
+            return
+        self.connection.close()
+        self.is_connected = False
+        return
+
+    def check_connection(self) -> StatusResponse:
+        """
+        Check the connection of the Hive database
+        :return: success status and error message if error occurs
+        """
+
+        response = StatusResponse(False)
+        need_to_close = self.is_connected is False
+
+        try:
+            self.connect()
+            response.success = True
+        except Exception as e:
+            log.error(f'Error connecting to Hive {self.connection_data["database"]}, {e}!')
+            response.error_message = str(e)
+
+        if response.success is True and need_to_close:
+            self.disconnect()
+        if response.success is False and self.is_connected is True:
+            self.is_connected = False
+
+        return response
+
+    def native_query(self, query: str) -> Response:
+        """
+        Receive SQL query and runs it
+        :param query: The SQL query to run in Hive
+        :return: returns the records from the current recordset
+        """
+
+        need_to_close = self.is_connected is False
+
+        connection = self.connect()
+        with connection.cursor() as cur:
+            try:
+                cur.execute(query)
+                result = cur.fetchall()
+                if result:
+                    response = Response(
+                        RESPONSE_TYPE.TABLE,
+                        pd.DataFrame(
+                            result,
+                            columns=[x[0].split('.')[1] for x in cur.description]
path: mindsdb/integrations/handlers/hive_handler/hive_handler.py
text: @user1:
If query='show tables', then cur.description[0] = 'tab_name' (without dot), therefore `.split('.')[1]` raise error. let change it to `.split('.')[-1]`, that should fix it.

@author:
Hi @user1 ,
Thank you for your observation. Find the fix in the latest commits.