packaging/src/docker/thirdparties/polaris/README.md
This package contains a docker-compose-based setup integrating Apache Hive and Polaris. It allows Hive to use an Iceberg REST catalog secured with oauth2 provided by Polaris.
This diagram illustrates the key docker-compose components and their interactions in this setup:
+-------------------+ +-------------------+
| | RESTCatalog | |
| Hive | (REST API) | Polaris |<-------+
| (HiveServer2) +-------------->| Server | |
| | oAuth2 | | |
+--------+----------+ (REST API) +---------+---------+ | creates:
| | | catalog,
data | metadata files | | principal,
files +------------------------------------+ | roles,
| | grants (REST API)
v |
+-------------------+ +-------------------+ |
| | creates dir | | |
| /warehouse |<--------------+ Polaris-init +--------+
| (Docker volume) | syncs | container |
| | permissions | |
+-------------------+ +-------------------+
$HIVE_HOME environment variable pointing to Hive installation (for connecting to Beeline)export HIVE_VERSION=4.2.0-SNAPSHOT
docker-compose up -d
"${HIVE_HOME}/bin/beeline" -u "jdbc:hive2://localhost:10001/default" -n hive -p hive
docker-compose down -v
# A realm provides logical isolation for different Polaris environments.
polaris.realm-context.realms: POLARIS
# Initial bootstrap credentials for the Polaris server.
# The format is: <realm-name>,<client-id>,<client-secret>
POLARIS_BOOTSTRAP_CREDENTIALS: POLARIS,iceberg-client,iceberg-client-secret`
HiveRESTCatalogClient for connecting to Iceberg REST catalog (Polaris).hive-site.xml:
<property>
<name>metastore.catalog.default</name>
<value>ice01</value>
<description>Sets the default Iceberg catalog for Hive. Here, "ice01" is used.</description>
</property>
<property>
<name>metastore.client.impl</name>
<value>org.apache.iceberg.hive.client.HiveRESTCatalogClient</value>
<description>Specifies the client implementation to use for accessing Iceberg via REST.</description>
</property>
<property>
<name>iceberg.catalog.ice01.uri</name>
<value>http://polaris:8181/api/catalog</value>
<description>URI of the Iceberg REST server (Polaris). Hive will send catalog requests here.</description>
</property>
<property>
<name>iceberg.catalog.ice01.type</name>
<value>rest</value>
<description>Defines the catalog type as "rest", indicating it uses a REST API backend.</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>file:///warehouse</value>
<description>Defines the warehouse location, required for Polaris</description>
</property>
<!-- Iceberg REST Catalog: OAuth2 authentication -->
<property>
<name>iceberg.catalog.ice01.rest.auth.type</name>
<value>oauth2</value>
<description>Configures Hive to use OAuth2 for authenticating requests to the REST catalog.</description>
</property>
<property>
<name>iceberg.catalog.ice01.oauth2-server-uri</name>
<value>http://polaris:8181/api/catalog/v1/oauth/tokens</value>
<description>URL of the Polaris OAuth2 token endpoint used to request access tokens.</description>
</property>
<property>
<name>iceberg.catalog.ice01.credential</name>
<value>iceberg-client:iceberg-client-secret</value>
<description>Client credentials (ID and secret) used to authenticate with Keycloak.</description>
</property>
<property>
<name>iceberg.catalog.ice01.scope</name>
<value>PRINCIPAL_ROLE:ALL</value>
<description>oAuth2 scope tied to the principal role defined in Polaris</description>
</property>
hive-net.