World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#844] refactor(doc): Rewrite doc of Apache Hive catalog (#1067)
mchadese124837891f5
diff --git a/docs/apache-hive-catalog.md b/docs/apache-hive-catalog.mdnew file mode 100644index 0000000000..1c77fd0998--- /dev/null+++ b/docs/apache-hive-catalog.md@@ -0,0 +1,175 @@+---+title: "Apache Hive catalog"+slug: /apache-hive-catalog+date: 2023-12-10+keyword: hive catalog+license: "Copyright 2023 Datastrato Pvt Ltd.+This software is licensed under the Apache License version 2."+---++## Introduction++Gravitino offers the capability to utilize [Apache Hive](https://hive.apache.org) 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.+* The Gravitino must have network access to the Hive metastore service with the Thrift protocol.++:::note+The Hive catalog is available for Apache Hive **2.x** only. Support for Apache Hive 3.x is under development.+:::++## Catalog++### Catalog Capabilities++The Hive catalog supports to create, update, and delete databases and tables in the HMS.++### Catalog Properties++| Property Name | Description | Default Value | Required | Since Version |+|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|---------------|+| `metastore.uris` | The Hive metastore service URIs, separate multiple addresses with commas. Such as `thrift://127.0.0.1:9083` | (none) | Yes | 0.2.0 |+| `client.pool-size` | The maximum number of Hive metastore clients in the pool for Gravitino. | 1 | No | 0.2.0 |+| `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 | 0.2.0 |++### Catalog Operations++see [Manage Metadata Using Gravitino](./manage-metadata-using-gravitino#catalogs-operations).++## Schema++### Schema Capabilities++The Hive catalog supports to create, update, and delete 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. In addition, you can also define your own key-value pair properties, which can also be transmitted to the underlying Hive database.++| Property name | Description | Default value | Required | Since Version |+|---------------|--------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|----------|---------------|+| `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 | 0.1.0 |++### Schema Operations++see [Manage Metadata Using Gravitino](./manage-metadata-using-gravitino#schemas-operations).+++## Table++### Table Capabilities++The Hive catalog supports to create, update, and delete tables in the HMS.++#### Table Partitions++The Hive catalog supports [partitioned tables](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-PartitionedTables). Users can create partitioned tables in the Hive catalog with specific partitioning attribute.+Although Gravitino supports several partitioning strategies, the Apache Hive inherently only supports a single partitioning strategy(partitioned by column), therefore the Hive catalog only support `Identity` partitioning.++:::caution+The `fieldName` specified in the partitioning attribute must be a column defined in the table.+:::++#### Table Sort Orders and Distributions++The Hive catalog supports [bucketed sorted tables](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-BucketedSortedTables). Users can create bucketed sorted tables in the Hive catalog with specific `distribution` and `sortOrders` attributes.+Although Gravitino supports several distribution strategies, the Apache Hive inherently only supports a single distribution strategy(clustered by column), therefore the Hive catalog only support `Hash` distribution.++:::caution+The `fieldName` specified in the `distribution` and `sortOrders` attribute must be a column defined in the table.+:::++#### Table Column Types++The Hive catalog supports all data types defined in the [Hive Language Manual](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types).+The following table lists the data types mapped from the Hive catalog to the Gravitino.++| Hive Data Type | Gravitino Data Type | Since Version |+|-----------------------------|---------------------|---------------|+| `boolean` | `boolean` | 0.2.0 |+| `tinyint` | `byte` | 0.2.0 |+| `smallint` | `short` | 0.2.0 |+| `int`/`integer` | `integer` | 0.2.0 |+| `bigint` | `long` | 0.2.0 |+| `float` | `float` | 0.2.0 |+| `double`/`double precision` | `double` | 0.2.0 |+| `decimal` | `decimal` | 0.2.0 |+| `string` | `string` | 0.2.0 |+| `char` | `char` | 0.2.0 |+| `varchar` | `varchar` | 0.2.0 |+| `timestamp` | `timestamp` | 0.2.0 |+| `date` | `date` | 0.2.0 |+| `interval_year_month` | `interval_year` | 0.2.0 |+| `interval_day_time` | `interval_day` | 0.2.0 |+| `binary` | `binary` | 0.2.0 |+| `array` | `array` | 0.2.0 |+| `map` | `map` | 0.2.0 |+| `struct` | `struct` | 0.2.0 |+| `uniontype` | `uniontype` | 0.2.0 |++### Table Properties++Table properties supply or set metadata for the underlying Hive tables.+The following table lists predefined table properties for the Hive table. In addition, you can also define your own key-value pair properties, which can also be transmitted to the underlying Hive table.++| Property Name | Description | Default Value | Required | Since version |+|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|----------|---------------|+| `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 | 0.2.0 |+| `table-type` | Type of the table. Valid values include `MANAGED_TABLE` and `EXTERNAL_TABLE`. | `MANAGED_TABLE` | No | 0.2.0 |+| `format` | The table file format. Valid values include `TEXTFILE`, `SEQUENCEFILE`, `RCFILE`, `ORC`, `PARQUET`, `AVRO`, `JSON`, `CSV`, and `REGEX`. | `TEXTFILE` | No | 0.2.0 |+| `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 | 0.2.0 |+| `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 | 0.2.0 |+| `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 | 0.2.0 |+| `serde.parameter.` | The prefix of the serde parameter. Such as `"serde.parameter.orc.create.index" = "true"` indicate `ORC` serde lib to create row indexes | (none) | No | 0.2.0 |++Some properties are reserved, which are automatically added and managed by Hive. Users are not allowed to set these properties.++| Property Name | Description | Since Version |+|-------------------------|---------------------------------------------------|---------------|+| `comment` | Used to store the table comment. | 0.2.0 |+| `numFiles` | Used to store the number of files in the table. | 0.2.0 |+| `totalSize` | Used to store the total size of the table. | 0.2.0 |+| `EXTERNAL` | Indicates whether the table is an external table. | 0.2.0 |+| `transient_lastDdlTime` | Used to store the last DDL time of the table. | 0.2.0 |++### Table Operations++#### Alter Operations++Gravitino has already defined a unified set of [metadata operation interfaces](./manage-metadata-using-gravitino#alter-a-table), and almost all [Hive Alter operations](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-AlterTable/Partition/Column) have corresponding table update request 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 request.++##### Alter Table++| Hive Alter Operation | Gravitino Table Update Request | Since Version |+|-----------------------------------------------|--------------------------------|---------------|+| `Rename Table` | `Rename table` | 0.2.0 |+| `Alter Table Properties` | `Set a table property` | 0.2.0 |+| `Alter Table Comment` | `Update comment` | 0.2.0 |+| `Alter SerDe Properties` | `Set a table property` | 0.2.0 |+| `Remove SerDe Properties` | `Remove a table property` | 0.2.0 |+| `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, Although Apache Hive change the comment of a table by modifying the comment property of the table.+:::++##### Alter Column++| Hive Alter Operation | Gravitino Table Update Request | Since Version |+|--------------------------|-----------------------------------|---------------|+| `Change Column Name` | `Rename a column` | 0.2.0 |+| `Change Column Type` | `Update the type of a column` | 0.2.0 |+| `Change Column Position` | `Update the position of a column` | 0.2.0 |+| `Change Column Comment` | `Update the column comment` | 0.2.0 |++##### Alter Partition++:::note+Support for altering partitions is under development.+:::diff --git a/docs/gravitino-manage-hive.md b/docs/gravitino-manage-hive.mddeleted file mode 100644index 2482fe88fa..0000000000--- a/docs/gravitino-manage-hive.md+++ /dev/null@@ -1,175 +0,0 @@-----title: "How to use Gravitino to manage Apache Hive metadata"-date: 2023-10-20-license: "Copyright 2023 Datastrato Pvt Ltd.-This software is licensed under the Apache License version 2."-----## Using Apache Hive as a catalog in Gravitino--Gravitino offers the capability to utilize Apache Hive as a catalog for metadata management. This guide leads you through the process of creating a catalog using Hive in Gravitino.--### Requirements--* The Hive catalog requires a Hive Metastore Service (HMS), or a compatible implementation of the HMS, such as AWS Glue.-* The Gravitino must have network access to the Hive metastore service with the Thrift protocol.-* Support is available for Apache Hive 2.x.-* Before you create a Hive catalog, make sure you have already created a Metalake. If you haven't done so, please follow the Metalake creation steps.--## Creating an Apache Hive catalog-To create a Hive catalog, use the following steps:--Submit a catalog JSON example to the Gravitino server using the URL format:--```shell-http://{GravitinoServerHost}:{GravitinoServerPort}/api/metalakes/{Your_metalake_name}/catalogs-```--Example JSON:--```json- {- "name": "test_hive_catalog",- "comment": "my test Hive catalog",- "type": "RELATIONAL",- "provider": "hive",- "properties": {- "metastore.uris": "thrift://127.0.0.1:9083"- }- }-```--* `name`: The name of the created Hive catalog.-* `comment`: Optional, user custom catalog comment.-* `provider`: Must set this to "hive" to use Hive as the catalog provider.-* `type`: Must set this to "RELATIONAL" because Hive has a relational data structure, like `db.table`.-* `properties`: The properties of the Hive catalog. For more property information see the following catalog properties table.--### Catalog properties--| Property name | Description | example value | Since version |-|---------------------|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|---------------|-| `metastore.uris` | This is a required configuration, and it should be the Hive metastore service URIs, separate multiple addresses with commas. | `thrift://127.0.0.1:9083` | 0.2.0 |-| `client.pool-size` | The maximum number of Hive metastore clients in the pool for Gravitino. 1 by default value. | 1 | 0.2.0 |-| `gravitino.bypass.` | Property name with this prefix passed down to the underlying HMS client for use. Empty by default value. | `gravitino.bypass.hive.metastore.failure.retries = 3` indicate 3 times of retries upon failure of Thrift metastore calls | 0.2.0 |--## Creating an Apache Hive schema--After creating the catalog, you can submit a schema JSON example to the Gravitino server using the URL format:--```shell-http://{GravitinoServerHost}:{GravitinoServerPort}/api/metalakes/{metalake}/catalogs/{catalog}/schemas-```--Example JSON:--```json-{- "name": "test_schema",- "comment": "my test schema",- "properties": {- "location": "/user/hive/warehouse"- }-}-```--* `name`: The name of the created Hive database.-* `comment`: Optional, user custom Hive database comment.-* `properties`: The properties of the Hive database. For more property information see the following schema properties table. You can pass down other properties to the underlying Hive database parameters.--### Schema properties--| Property name | Description | example value | Since version |-|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|---------------|-| `location` | The directory for Hive database storage. Not required, HMS uses the value of `hive.metastore.warehouse.dir` in the hive-site.xml by default. | `/user/hive/warehouse` | 0.1.0 |--## Creating an Apache Hive table--After creating the schema, you can submit a table JSON example to the Gravitino server using the URL format:--```shell-http://{GravitinoServerHost}:{GravitinoServerPort}/api/metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/tables-```--Example JSON:--```json-{- "name": "test_table",- "comment": "my test table",- "columns": [- {- "name": "id",- "type": "integer",- "comment": "id column comment",- "nullable": true- },- {- "name": "name",- "type": "string",- "comment": "name column comment",- "nullable": true- },- {- "name": "age",- "type": "integer",- "comment": "age column comment",- "nullable": true- },- {- "name": "dt",- "type": "date",- "comment": "dt column comment",- "nullable": true- }- ],- "partitions": [- {- "strategy": "identity",- "fieldName": ["dt"]- }- ],- "distribution": {- "strategy": "hash",- "number": 32,- "expressions": [- {- "expressionType": "field",- "fieldName": ["id"]- }- ]- },- "sortOrders": [- {- "expression": {- "expressionType": "field",- "fieldName": ["age"]- },- "direction": "asc",- "nullOrdering": "first"- }- ],- "properties": {- "format": "ORC"- }-}-```--* `name`: The name of the created Hive table.-* `comment`: Optional, user custom Hive table comment.-* `columns`: The columns of the Hive table.-* `partitions`: Optional, the partitions of the Hive table, the previous example is a partitioned table with `dt` column.-* `distribution`: Optional, equivalent to the `CLUSTERED BY` clause in Hive DDL, the previous example table bucketed or cluster on the `id` column.-* `sortOrders`: Optional, equivalent to the `SORTED BY` clause in Hive DDL, the previous example table shows shorted data in increasing order of `age` in each bucket.-* `properties`: The properties of the Hive table. For more property information see the following table properties table. You can pass down other properties to the underlying Hive table parameters.--### Table properties--| Configuration item | Description | example value | Since version |-|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|---------------|-| `location` | The location for table storage. Not required, HMS will use the database location as the parent directory by default. | `/user/hive/warehouse/test_table` | 0.2.0 |-| `table-type` | Type of the table. Valid values include `MANAGED_TABLE` and `EXTERNAL_TABLE`. `MANAGED_TABLE` by default value. | `MANAGED_TABLE` | 0.2.0 |-| `format` | The table file format. Valid values include `TEXTFILE`, `SEQUENCEFILE`, `RCFILE`, `ORC`, `PARQUET`, `AVRO`, `JSON`, `CSV`, and `REGEX`. `TEXTFILE` by default value. | `ORC` | 0.2.0 |-| `input-format` | The input format class for the table. The property `format` sets the default value `org.apache.hadoop.mapred.TextInputFormat` and can change it to a different default. | `org.apache.hadoop.hive.ql.io.orc.OrcInputFormat` | 0.2.0 |-| `output-format` | The output format class for the table. The property `format` sets the default value `org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat` and can change it to a different default. | `org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat` | 0.2.0 |-| `serde-lib` | The serde library class for the table. The property `format` sets the default value `org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe` and can change it to a different default. | `org.apache.hadoop.hive.ql.io.orc.OrcSerde` | 0.2.0 |-| `serde.parameter.` | The prefix of the serde parameter, empty by default. | `"serde.parameter.orc.create.index" = "true"` indicate `ORC` serde lib to create row indexes | 0.2.0 |