# Stackable Operator for Apache Hive

> Manage Apache Hive metastores on Kubernetes with the Stackable Operator. Integrates with Trino and Spark.

-   [GitHub](https://github.com/stackabletech/hive-operator/)

-   [Feature Tracker](https://features.stackable.tech/unified)

-   [CRD documentation](https://crds.stackable.tech/hive-operator/26.7.0/)


This is an operator for Kubernetes that can manage [Apache Hive](https://hive.apache.org) metastores. The Apache Hive metastore (HMS) was originally developed as part of Apache Hive. It stores information on the location of tables and partitions in file and blob storages such as [Apache HDFS](https://docs.stackable.tech/home/stable/hdfs/index.md) and S3 and is now used by other tools besides Hive as well to access tables in files. This operator does not support deploying Hive itself, but [Trino](https://docs.stackable.tech/home/stable/trino/index.md) is recommended as an alternative query engine.

## Getting started

Follow the [Getting started guide](https://docs.stackable.tech/home/stable/hive/getting_started/index.md) which guides you through the installation of the Stackable Hive operator and its dependencies. It walks you through setting up a Hive metastore and connecting it to a demo Postgres database and a Minio instance to store data in.

Afterwards you can consult the [Usage guide](https://docs.stackable.tech/home/stable/hive/usage-guide/index.md) to learn more about tailoring your Hive metastore configuration to your needs, or have a look at the [demos](https://docs.stackable.tech/home/stable/hive/index.md) for some example setups with either [Trino](https://docs.stackable.tech/home/stable/trino/index.md) or [Spark](https://docs.stackable.tech/home/stable/spark-k8s/index.md).

## Operator model

The operator manages the _HiveCluster_ custom resource. The cluster implements a single `metastore` [role](https://docs.stackable.tech/home/stable/concepts/stacklet/index.md).

![A diagram depicting the Kubernetes resources created by the Stackable operator for Apache Hive](https://docs.stackable.tech/home/stable/hive/_images/hive_overview.drawio.svg)

For every role group the operator creates a ConfigMap and StatefulSet which can have multiple replicas (Pods). Every role group is accessible through its own Service, and there is a Service for the whole cluster.

The operator creates a [service discovery ConfigMap](https://docs.stackable.tech/home/stable/concepts/service-discovery/index.md) for the Hive metastore instance. The discovery ConfigMap contains information on how to connect to the HMS.

## Dependencies

The Stackable operator for Apache Hive depends on the Stackable [commons](https://docs.stackable.tech/home/stable/commons-operator/index.md), [secret](https://docs.stackable.tech/home/stable/secret-operator/index.md) and [listener](https://docs.stackable.tech/home/stable/listener-operator/index.md) operators.

## Required external component: An SQL database

The Hive metastore requires an SQL database to store metadata. Consult the [required external components page](https://docs.stackable.tech/home/stable/hive/required-external-components/index.md) for an overview of the supported databases and minimum supported versions.

## Demos

Three demos make use of the Hive metastore.

The [spark-k8s-anomaly-detection-taxi-data](https://docs.stackable.tech/home/stable/demos/spark-k8s-anomaly-detection-taxi-data/index.md) and [trino-taxi-data](https://docs.stackable.tech/home/stable/demos/trino-taxi-data/index.md) use the HMS to store metadata information about taxi data. The first demo then analyzes the data using [Apache Spark](https://docs.stackable.tech/home/stable/spark-k8s/index.md) and the second one using [Trino](https://docs.stackable.tech/home/stable/trino/index.md).

The [data-lakehouse-iceberg-trino-spark](https://docs.stackable.tech/home/stable/demos/data-lakehouse-iceberg-trino-spark/index.md) demo is the biggest demo available. It uses both Spark and Trino for analysis.

## Why is the Hive query engine not supported?

Only the metastore is supported, not Hive itself. There are several reasons why running Hive on Kubernetes may not be an optimal solution. The most obvious reason is that Hive requires YARN as an execution framework, and YARN assumes much of the same role as Kubernetes - i.e. assigning resources. For this reason we provide [Trino](https://docs.stackable.tech/home/stable/trino/index.md) as a query engine in the Stackable Data Platform instead of Hive. Trino still uses the Hive Metastore, hence the inclusion of this operator as well. Trino should offer all the capabilities Hive offers including a lot of additional functionality, such as connections to other data sources.

Additionally, Tables in the HMS can also be accessed from [Apache Spark](https://docs.stackable.tech/home/stable/spark-k8s/index.md).

## Supported versions

The Stackable operator for Apache Hive currently supports the Hive versions listed below. To use a specific Hive version in your HiveCluster, you have to specify an image - this is explained in the [Product image selection](https://docs.stackable.tech/home/stable/concepts/product-image-selection/index.md) documentation. The operator also supports running images from a custom registry or running entirely customized images; both of these cases are explained under [Product image selection](https://docs.stackable.tech/home/stable/concepts/product-image-selection/index.md) as well.

-   4.2.0 (LTS)

-   4.0.1 (deprecated)

-   4.0.0 (deprecated)

-   3.1.3 (deprecated)


### Hive 4 issues

Hive 4 has known compatibility issues, especially when using it with Iceberg or Trino. The missing compatibility with Iceberg also means that Spark jobs using this storage may fail.

Be aware of upgrading Hive (e.g. 4.0.0 to 4.0.1 or 4.0.1 to Hive 4.1.0), as this upgrade is not easily reversible. Test the new version before upgrading your production workloads and take backups of your database before starting an upgrade.

**Workaround:** If you encounter issues with Hive 4.x, use Hive 3.1.3 instead until these upstream issues are resolved.

For more details, see:

-   [Our Stackable tracking issue](https://github.com/stackabletech/hive-operator/issues/626)

-   [Trino: Repeated ANALYZE fails on Hive metastore 4.0.x](https://github.com/trinodb/trino/issues/26214)

-   [Iceberg: org.apache.thrift.TApplicationException: Invalid method name: 'get\_table'](https://github.com/apache/iceberg/issues/12878)


## Useful links

-   The [hive-operator](https://github.com/stackabletech/hive-operator/) GitHub repository

-   The operator feature overview in the [feature tracker](https://features.stackable.tech/unified)

-   The [HiveCluster](https://crds.stackable.tech/26.7.0/hive.stackable.tech/hivecluster/v1alpha1/) CRD documentation
