World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
title: "Hive Catalog" slug: "/apache-hive-catalog" date: 2023-12-10 keyword: "hive catalog" license: "This software is licensed under the Apache License version 2."
Introduction
Apache Gravitino offers the capability to utilize Apache Hive as a catalog for metadata management.
Requirements and Limitations
- The Hive catalog requires a Hive Metastore Service (HMS), or a compatible implementation of the HMS, such as AWS Glue.
- Gravitino must have network access to the Hive metastore service using the Thrift protocol.
:::note The Hive catalog supports HMS versions 2.x and 3.x. it can automatically detect the HMS version. :::
Catalog
Catalog Capabilities
The Hive catalog supports creating, updating, and deleting databases and tables in the HMS.
Catalog Properties
Besides the common catalog properties, the Hive catalog has the following properties:
| Property Name | Description | Default Value | Required |
|---|---|---|---|
metastore.uris |
The Hive metastore service URIs, separate multiple addresses with commas. Such as thrift://127.0.0.1:9083 |
(none) | Yes |
client.pool-size |
The maximum number of Hive metastore clients in the pool for Gravitino. | 1 | No |
gravitino.bypass. |
Property name with this prefix passed down to the underlying HMS client for use. Such as gravitino.bypass.hive.metastore.failure.retries = 3 indicate 3 times of retries upon failure of Thrift metastore calls |
(none) | No |
client.pool-cache.eviction-interval-ms |
The cache pool eviction interval. | 300000 | No |
impersonation-enable |
Enable user impersonation for Hive catalog. | false | No |
kerberos.principal |
The Kerberos principal for the catalog. You should configure gravitino.bypass.hadoop.security.authentication, gravitino.bypass.hive.metastore.kerberos.principal and gravitino.bypass.hive.metastore.sasl.enabledif you want to use Kerberos. |
(none) | required if you use kerberos |
kerberos.keytab-uri |
The uri of key tab for the catalog. Now supported protocols are https, http, ftp, file. |
(none) | required if you use kerberos |
kerberos.check-interval-sec |
The interval to check validity of the principal | 60 | No |
kerberos.keytab-fetch-timeout-sec |
The timeout to fetch key tab | 60 | No |
list-all-tables |
Whether to list all tables in a database, including non-Hive tables such as Iceberg, Paimon, and Hudi. When false, non-Hive tables are filtered out on a best-effort basis; see the note below for known limitations. | false | No |
default.catalog |
The default catalog name for the Hive3 metastore backend; this configuration is ignored when using a Hive2 metastore. | hive | No |
:::note
When list-all-tables=false, the Hive catalog removes the following on a best-effort basis:
- Iceberg tables (table property
table_type=ICEBERG) - Paimon tables (table property
table_type=PAIMON) - Hudi tables (table property
provider=hudi), together with their_roand_rtsiblings
Known limitation. Filtering is performed server-side via the Hive Metastore, which only
supports exact-key lookups on dot-free property keys. Hudi tables registered directly by Spark
(e.g. via saveAsTable) typically only set spark.sql.sources.provider=hudi without also
setting provider=hudi, so they cannot be filtered out and will appear in the listing.
Workaround. Add a dot-free provider=hudi property to such tables so the server-side
filter can match them. Either after creation:
ALTER TABLE <db>.<table> SET TBLPROPERTIES ('provider'='hudi');
or at write time via Hudi's Hive sync option:
df.write.format("hudi")
.option("hoodie.datasource.hive_sync.table_properties", "provider=hudi")
.saveAsTable("<db>.<table>")
The corresponding _ro / _rt siblings are removed automatically based on the base table name.
:::
When using Gravitino with Trino, pass the Trino Hive connector configuration using the trino.bypass. prefix. For example, using trino.bypass.hive.config.resources to pass the hive.config.resources to the Gravitino Hive catalog in Trino runtime.
When using Gravitino with Spark, pass the Spark Hive connector configuration using the spark.bypass. prefix. For example, using spark.bypass.hive.exec.dynamic.partition.mode to pass the hive.exec.dynamic.partition.mode to the Spark Hive connector in Spark runtime.
When using Gravitino authorization for Hive with Apache Ranger, see the Authorization Hive with Ranger properties
Identifier Case Behavior
Schema, table, and view identifiers are case-insensitive; you can use any casing. Column identifiers remain case-sensitive.
:::caution After upgrading, if loading an existing mixed-case object reports a retained identifier conflict, Gravitino does not support metadata-only unregister of an individual external object. Use this catalog-wide recovery procedure:
- Have an administrator force-drop the Gravitino catalog. This deletes every Gravitino registration and its privileges, tags, and other relationships in the catalog. It does not drop the Hive Metastore databases, tables, views, or physical data.
- Recreate the Gravitino catalog and load the objects again. Keep the existing
gravitino.identifierproperties; deleted registrations do not block new imports. - Reapply any privileges, tags, or other governance relationships that the new registrations need.
A source identifier can have only one active Gravitino registration. Coordinate with other Gravitino catalogs that share the external source before resetting a catalog. :::
Catalog Operations
Refer to Manage Catalogs and Schemas for more details.
:::note
Sensitive catalog properties such as credential-vending keys are hidden from the default load catalog response. Recover credential fields via the credential vending API (getCredentials). Other non-credential secrets (secret-manager URNs, declared hidden properties, undeclared sensitive-named keys) use getSecrets / GET .../objects/{type}/{fullName}/secrets.
:::
Schema
Schema Capabilities
The Hive catalog supports creating, updating, and deleting databases in the HMS.
Schema Properties
Schema properties supply or set metadata for the underlying Hive database. The following table lists predefined schema properties for the Hive database. Additionally, you can define your own key-value pair properties and transmit them to the underlying Hive database.
| Property name | Description | Default value | Required |
|---|---|---|---|
location |
The directory for Hive database storage, such as /user/hive/warehouse. |
HMS uses the value of hive.metastore.warehouse.dir in the hive-site.xml by default. |
No |
Schema Operations
see Manage Catalogs and Schemas.
Table
Table Capabilities
- The Hive catalog supports creating, updating, and deleting tables in the HMS.
- Column
NOT NULLandDEFAULTconstraints are supported only when the connected HMS is Hive 3.x; on Hive 2.x they are rejected.
Table Partitioning
The Hive catalog supports partitioned tables. Users can create partitioned tables in the Hive catalog with the specific partitioning attribute.
Although Gravitino supports several partitioning strategies, Apache Hive inherently only supports a single partitioning strategy (partitioned by column). Therefore, the Hive catalog only supports Identity partitioning.
:::caution
The fieldName specified in the partitioning attribute must be the name of a column defined in the table.
:::
Table Sort Orders and Distributions
The Hive catalog supports bucketed sorted tables. Users can create bucketed sorted tables in the Hive catalog with specific distribution and sortOrders attributes.
Although Gravitino supports several distribution strategies, Apache Hive inherently only supports a single distribution strategy (clustered by column). Therefore the Hive catalog only supports Hash bucketing. Use none (zero buckets and no expressions) for an unbucketed table. Other distribution strategies are rejected rather than silently converted to hash bucketing.
:::caution
The fieldName specified in the distribution and sortOrders attribute must be the name of a column defined in the table.
:::
Table Column Types
When creating a table, use the Gravitino types in the right column in REST requests and the
corresponding Types in the Java API. The left column shows the
Hive types stored in the metastore.
For example, "type": "long" creates a Hive bigint column, and
"type": {"type": "list", "elementType": "string"} creates a Hive array<string> column.
| Hive Data Type | Gravitino Data Type |
|---|---|
boolean |
boolean |
tinyint |
byte |
smallint |
short |
int/integer |
integer |
bigint |
long |
float |
float |
double/double precision |
double |
decimal(p,s) |
decimal(p,s) |
string |
string |
char(n) |
char(n) |
varchar(n) |
varchar(n) |
timestamp |
timestamp |
date |
date |
interval_year_month |
interval_year |
interval_day_time |
interval_day |
binary |
binary |
array |
list |
map |
map |
struct |
struct |
uniontype |
union |
Specify both precision (1–38) and scale (0 through precision) for decimal(p,s), for example
decimal(10,2). The length of char(n) ranges from 1 to 255 and the length of varchar(n) from
1 to 65535. Hive accepts timestamp without a time zone and rejects timestamp_tz on create.
When loading a table, Gravitino represents unmapped Hive types as an external type. Table creation requires a mapped Gravitino type. Hive also rejects comments on nested struct fields (HIVE-26593).
Table Properties
On create, format selects defaults for input-format, output-format, and serde-lib.
When loading the table, read those properties for the effective storage classes. HMS stores them in
the storage descriptor and Gravitino does not reconstruct the format shorthand.
The following table lists predefined table properties for a Hive table. Additionally, you can define your own key-value pair properties and transmit them to the underlying Hive database.
:::note Reserved: Fields that cannot be passed to the Gravitino server.
Immutable: Fields that cannot be modified once set. :::
| Property Name | Description | Default Value | Required | Reserved | Immutable |
|---|---|---|---|---|---|
location |
The location for table storage, such as /user/hive/warehouse/test_table. |
HMS uses the database location as the parent directory by default. | No | No | Yes |
table-type |
Type of the table. Valid values include MANAGED_TABLE and EXTERNAL_TABLE. |
MANAGED_TABLE |
No | No | Yes |
format |
The table file format. Valid values include TEXTFILE, SEQUENCEFILE, RCFILE, ORC, PARQUET, AVRO, JSON, CSV, and REGEX. |
TEXTFILE |
No | No | Yes |
input-format |
The input format class for the table, such as org.apache.hadoop.hive.ql.io.orc.OrcInputFormat. |
The property format sets the default value org.apache.hadoop.mapred.TextInputFormat and can change it to a different default. |
No | No | Yes |
output-format |
The output format class for the table, such as org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat. |
The property format sets the default value org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat and can change it to a different default. |
No | No | Yes |
serde-lib |
The serde library class for the table, such as org.apache.hadoop.hive.ql.io.orc.OrcSerde. |
The property format sets the default value org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe and can change it to a different default. |
No | No | Yes |
serde.parameter. |
The prefix of the serde parameter, such as "serde.parameter.orc.create.index" = "true", indicating ORC serde lib to create row indexes |
(none) | No | No | Yes |
serde-name |
The name of the serde | Table name by default. | No | No | Yes |
comment |
Used to store a table comment. | (none) | No | Yes | No |
numFiles |
Used to store the number of files in the table. | (none) | No | Yes | No |
totalSize |
Used to store the total size of the table. | (none) | No | Yes | No |
EXTERNAL |
Indicates whether the table is external. | (none) | No | Yes | No |
transient_lastDdlTime |
Used to store the last DDL time of the table. | (none) | No | Yes | No |
Table Indexes
- Doesn't support table indexes.
Table Operations
Refer to Manage Relational Metadata Using Gravitino for more details.
Alter Operations
Gravitino has already defined a unified set of metadata operation interfaces, and almost all Hive Alter operations have corresponding table update requests which enable you to change the struct of an existing table. The following table lists the mapping relationship between Hive Alter operations and Gravitino table update requests.
Alter table
| Hive Alter Operation | Gravitino Table Update Request |
|---|---|
Rename Table |
Rename table |
Alter Table Properties |
Set a table property |
Alter Table Comment |
Update comment |
Alter SerDe Properties |
Set a table property |
Remove SerDe Properties |
Remove a table property |
Alter Table Storage Properties |
Unsupported |
Alter Table Skewed or Stored as Directories |
Unsupported |
Alter Table Constraints |
Unsupported |
:::note
As Gravitino has a separate interface for updating the comment of a table, the Hive catalog sets comment as a reserved property for the table, preventing users from setting the comment property. Apache Hive can modify the comment property of the table.
:::
Alter column
| Hive Alter Operation | Gravitino Table Update Request |
|---|---|
Change Column Name |
Rename a column |
Change Column Type |
Update the type of a column |
Change Column Position |
Update the position of a column |
Change Column Comment |
Update the column comment |
Change Column Nullability |
Update the nullability of a column (Hive 3.x only) |
Change Column Default |
Update the default value of a column (Hive 3.x only) |
Alter partition
:::note Support for altering partitions is under development. :::
View
View Capabilities
- Supports list, create, load, alter, and drop for views stored in the Hive Metastore Service as
VIRTUAL_VIEW. - Each view must contain exactly one SQL representation.
- Supports creating views with the
hive,trino,flink, orsparkdialect. - When loading an existing HMS view, Gravitino automatically detects whether the view uses the
hive,trino,flink, orsparkdialect. - For the
hive,flink, andsparkdialects, omitdefaultCataloganddefaultSchemaor set both tonull. - For the
trinodialect,defaultSchemarequiresdefaultCatalogto also be set (a schema without a catalog cannot be represented). - The
trinodialect requires at least one output column, and is stored using Trino's own native "Presto View" Hive Metastore encoding, so a view created through Gravitino is interoperable with a native Trino/Presto Hive connector pointed at the same Hive Metastore, and vice versa. The HMSpresto_viewproperty this relies on is reserved and managed internally based on the view's dialect; it cannot be set or removed directly. Gravitino's view model cannot represent a native Trino view's owner,runAsInvoker, or SQL path, so replacing an existing native view that has a non-default value for any of them is rejected rather than silently discarding it. - The
flinkdialect requires at least one view property with the prefixflink.to be set. The Flink connector automatically setsflink.schema.num-columns; when using the REST API directly, set at least oneflink.*property explicitly. - The
sparkdialect requires thespark.sql.create.versionview property so the Hive catalog can identify Spark views when it loads them.
View Operations
Refer to Manage view metadata using Gravitino for more details.
Hive Catalog with S3 Storage
To create a Hive catalog with S3 storage, you can refer to the Hive catalog with S3 documentation. No special configurations are required for the Hive catalog to work with S3 storage.
The only difference is the storage location of the files, which is in S3. Use location to specify the S3 path for the database or table.
SerDe-derived schemas
Tables with <derived from deserializer> storage column types are resolved through Hive
Metastore's getFields API when loaded individually or in a batch. Ordinary tables do not
require an additional schema-resolution request. Hudi table listing filters raw storage
metadata without resolving unrelated table schemas, so an unresolvable non-Hudi SerDe
table does not prevent Hudi tables from being listed. Full schema batch reads still fail
if a requested table cannot be resolved. The table SerDe and its dependencies must
be available on the Hive Metastore classpath.
Hive 3's default storage schema reader cannot resolve these schemas. Configure the following
property in the Hive Metastore server's hive-site.xml and restart Hive Metastore:
<property>
<name>metastore.storage.schema.reader.impl</name>
<value>org.apache.hadoop.hive.metastore.SerDeStorageSchemaReader</value>
</property>
This server setting is also required when a Hive 2 client connects to a Hive 3 Metastore. If resolution fails or returns unresolved types, Gravitino reports an error with configuration guidance rather than treating the marker as a Hive data type.
Property, table-comment, and table-name changes preserve the original storage column schema
in Hive Metastore. Hive 2 HMS can reject even metadata-only alters when
hive.metastore.disallow.incompatible.col.type.changes=true, because its compatibility
check attempts to parse the stored marker as a type. Preserving the marker requires an
HMS administrator to evaluate setting this property to false on the server and restarting
HMS. This disables column type compatibility checks for all tables; Gravitino does not
change this server setting. If the check rejects the marker, the error explains this limitation.
Column changes on SerDe-derived tables are rejected: modify those schemas
through the SerDe or its external schema definition (for example, avro.schema.url) instead.