Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#1798] Improvement(doc): Upgrade doc for index, auto_increment, mysql_properties (#1834)

Clearvive27b25f418357
diff --git a/docs/apache-hive-catalog.md b/docs/apache-hive-catalog.md
index 4e038b4989..12b5d5c287 100644
--- a/docs/apache-hive-catalog.md
+++ b/docs/apache-hive-catalog.md
@@ -140,6 +140,10 @@ Hive automatically adds and manages some reserved properties. Users aren't allow
| `EXTERNAL` | Indicates whether the table is external. | 0.2.0 |
| `transient_lastDdlTime` | Used to store the last DDL time of the table. | 0.2.0 |
+### Table indexes
+
+- Doesn't support table indexes.
+
### Table operations
Refer to [Manage Metadata Using Gravitino](./manage-metadata-using-gravitino.md#table-operations) for more details.
diff --git a/docs/jdbc-mysql-catalog.md b/docs/jdbc-mysql-catalog.md
index 419ef71cf9..2acee1355e 100644
--- a/docs/jdbc-mysql-catalog.md
+++ b/docs/jdbc-mysql-catalog.md
@@ -9,6 +9,9 @@ license: "Copyright 2023 Datastrato Pvt Ltd.
This software is licensed under the Apache License version 2."
---
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
## Introduction
Gravitino provides the ability to manage MySQL metadata.
@@ -100,9 +103,113 @@ Please refer to [Manage Metadata Using Gravitino](./manage-metadata-using-gravit
MySQL doesn't support Gravitino `Boolean` `Fixed` `Struct` `List` `Map` `Timestamp_tz` `IntervalDay` `IntervalYear` `Union` `UUID` type.
:::
+#### Table column auto-increment
+
+- Supports setting auto-increment.
+
+:::notice
+MySQL setting an auto-increment column requires simultaneously setting a unique index; otherwise, an error will occur.
+:::
+
+<Tabs>
+<TabItem value="json" label="Json">
+
+```json
+{
+ "columns": [
+ {
+ "name": "id",
+ "type": "int",
+ "comment": "id column comment",
+ "nullable": false,
+ "autoIncrement": true
+ },
+ {
+ "name": "name",
+ "type": "varchar(500)",
+ "comment": "name column comment",
+ "nullable": true,
+ "autoIncrement": false
+ }
+ ],
+ "indexes": [
+ {
+ "indexType": "primary_key",
+ "name": "PRIMARY",
+ "fieldNames": [["id"]]
+ }
+ ]
+}
+```
+
+</TabItem>
+<TabItem value="java" label="Java">
+
+```java
+Column[] cols = new Column[] {
+ Column.of("id", Types.IntegerType.get(), "id column comment", false, true, null),
+ Column.of("name", Types.VarCharType.of(500), "Name of the user", true, false, null)
+};
+Index[] indexes = new Index[] {
+ Indexes.of(IndexType.PRIMARY_KEY, "PRIMARY", new String[][]{{"id"}})
+}
+```
+
+</TabItem>
+</Tabs>
+
### Table properties
-- Doesn't support table properties.
+Table properties support the following properties:
+
+| Property Name | Description | Required | Since version |
+|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|---------------|
+| `engine` | The engine used by the table. The default value is `InnoDB`. For example `MyISAM`, `MEMORY`, `CSV`, `ARCHIVE`, `BLACKHOLE`, `FEDERATED`, `ndbinfo`, `MRG_MYISAM`, `PERFORMANCE_SCHEMA`. | No | 0.4.0 |
+| `auto-increment-offset` | Used to specify the starting value of the auto-increment field. | No | 0.4.0 |
+
+- Doesn't support remove table properties. You can only modify values, not delete properties.
+
+### Table indexes
+
+- Supports PRIMARY_KEY and UNIQUE_KEY.
+
+:::notice
+The index name of the PRIMARY_KEY must be PRIMARY
+[Create table index](https://dev.mysql.com/doc/refman/8.0/en/create-table.html)
+:::
+
+<Tabs>
+<TabItem value="json" label="Json">
+
+```json
+{
+ "indexes": [
+ {
+ "indexType": "primary_key",
+ "name": "PRIMARY",
+ "fieldNames": [["id"]]
+ },
+ {
+ "indexType": "unique_key",
+ "name": "id_name_uk",
+ "fieldNames": [["id"] ,["name"]]
+ }
+ ]
+}
+```
+
+</TabItem>
+<TabItem value="java" label="Java">
+
+```java
+Index[] indexes = new Index[] {
+ Indexes.of(IndexType.PRIMARY_KEY, "PRIMARY", new String[][]{{"id"}}),
+ Indexes.of(IndexType.UNIQUE_KEY, "id_name_uk", new String[][]{{"id"} , {"name"}}),
+}
+```
+
+</TabItem>
+</Tabs>
### Table operations
diff --git a/docs/jdbc-postgresql-catalog.md b/docs/jdbc-postgresql-catalog.md
index a92e2934fe..c0fcb00901 100644
--- a/docs/jdbc-postgresql-catalog.md
+++ b/docs/jdbc-postgresql-catalog.md
@@ -9,6 +9,9 @@ license: "Copyright 2023 Datastrato Pvt Ltd.
This software is licensed under the Apache License version 2."
---
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
## Introduction
Gravitino provides the ability to manage PostgreSQL metadata.
@@ -107,10 +110,88 @@ Please refer to [Manage Metadata Using Gravitino](./manage-metadata-using-gravit
PostgreSQL doesn't support Gravitino `Fixed` `Struct` `List` `Map` `IntervalDay` `IntervalYear` `Union` `UUID` type.
:::
+#### Table column auto-increment
+
+- Supports setting auto-increment.
+
+<Tabs>
+<TabItem value="json" label="Json">
+
+```json
+{
+ "columns": [
+ {
+ "name": "id",
+ "type": "int",
+ "comment": "id column comment",
+ "nullable": false,
+ "autoIncrement": true
+ },
+ {
+ "name": "name",
+ "type": "varchar(500)",
+ "comment": "name column comment",
+ "nullable": true,
+ "autoIncrement": false
+ }
+ ]
+}
+```
+
+</TabItem>
+<TabItem value="java" label="Java">
+
+```java
+Column[] cols = new Column[] {
+ Column.of("id", Types.IntegerType.get(), "id column comment", false, true, null),
+ Column.of("name", Types.VarCharType.of(500), "Name of the user", true, false, null)
+};
+```
+
+</TabItem>
+</Tabs>
+
### Table properties
- Doesn't support table properties.
+### Table indexes
+
+- Supports PRIMARY_KEY and UNIQUE_KEY.
+
+<Tabs>
+<TabItem value="json" label="Json">
+
+```json
+{
+ "indexes": [
+ {
+ "indexType": "primary_key",
+ "name": "id_pk",
+ "fieldNames": [["id"]]
+ },
+ {
+ "indexType": "unique_key",
+ "name": "id_name_uk",
+ "fieldNames": [["id"] ,["name"]]
+ }
+ ]
+}
+```
+
+</TabItem>
+<TabItem value="java" label="Java">
+
+```java
+Index[] indexes = new Index[] {
+ Indexes.of(IndexType.PRIMARY_KEY, "PRIMARY", new String[][]{{"id"}}),
+ Indexes.of(IndexType.UNIQUE_KEY, "id_name_uk", new String[][]{{"id"} , {"name"}}),
+}
+```
+
+</TabItem>
+</Tabs>
+
### Table operations
Please refer to [Manage Metadata Using Gravitino](./manage-metadata-using-gravitino.md#table-operations) for more details.
diff --git a/docs/lakehouse-iceberg-catalog.md b/docs/lakehouse-iceberg-catalog.md
index 3825e5e342..f68c58ae76 100644
--- a/docs/lakehouse-iceberg-catalog.md
+++ b/docs/lakehouse-iceberg-catalog.md
@@ -232,6 +232,10 @@ The Gravitino server doesn't allow passing the following reserved fields.
| `identifier-fields` | The identifier fields for defining the table. |
| `write.distribution-mode` | Defines distribution of write data |
+### Table indexes
+
+- Doesn't support table indexes.
+
### Table operations
Please refer to [Manage Metadata Using Gravitino](./manage-metadata-using-gravitino.md#table-operations) for more details.
diff --git a/docs/manage-metadata-using-gravitino.md b/docs/manage-metadata-using-gravitino.md
index 575b2f8878..c67db97936 100644
--- a/docs/manage-metadata-using-gravitino.md
+++ b/docs/manage-metadata-using-gravitino.md
@@ -790,6 +790,17 @@ The following types that Gravitino supports:
The related java doc is [here](pathname:///docs/0.3.1/api/java/com/datastrato/gravitino/rel/types/Type.html).
+#### Table column auto-increment
+
+Auto-increment provides a convenient way to ensure that each row in a table has a unique identifier without the need for manually managing identifier allocation.
+The following catalogs support setting the table column auto-increment.
+
+| Catalog provider | Auto-increment mapping |
+|---------------------|-----------------------------------------------------------------------------------------------|
+| `jdbc-mysql` | [MySQL auto-increment mapping](./jdbc-mysql-catalog.md#table-column-auto-increment) |
+| `jdbc-postgresql` | [PostgreSQL auto-increment mapping](./jdbc-postgresql-catalog.md#table-column-auto-increment) |
+
+
#### Table property and type mapping
The following is the table property that Gravitino supports:
@@ -802,16 +813,19 @@ The following is the table property that Gravitino supports:
| `jdbc-postgresql` | [PostgreSQL table property](./jdbc-postgresql-catalog.md#table-properties) | [PostgreSQL type mapping](./jdbc-postgresql-catalog.md#table-column-types) |
+#### Table partitioning, bucketing, sort ordering and indexing
+
In addition to the basic settings, Gravitino supports the following features:
-| Feature | Description | Java doc |
-|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
-| Table partitioning | Equal to `PARTITION BY` in Apache Hive, It is a partitioning strategy that is used to split a table into parts based on partition keys. Some table engine may not support this feature | [Partition](pathname:///docs/0.3.1/api/java/com/datastrato/gravitino/dto/rel/partitions/Partitioning.html) |
-| Table bucketing | Equal to `CLUSTERED BY` in Apache Hive, Bucketing a.k.a (Clustering) is a technique to split the data into more manageable files/parts, (By specifying the number of buckets to create). The value of the bucketing column will be hashed by a user-defined number into buckets. | [Distribution](pathname:///docs/0.3.1/api/java/com/datastrato/gravitino/rel/expressions/distributions/Distribution.html) |
-| Table sort ordering | Equal to `SORTED BY` in Apache Hive, sort ordering is a method to sort the data in specific ways such as by a column or a function, and then store table data. it will highly improve the query performance under certain scenarios. | [SortOrder](pathname:///docs/0.3.1/api/java/com/datastrato/gravitino/rel/expressions/sorts/SortOrder.html) |
+| Feature | Description | Java doc |
+|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
+| Table partitioning | Equal to `PARTITION BY` in Apache Hive, It is a partitioning strategy that is used to split a table into parts based on partition keys. Some table engine may not support this feature | [Partition](pathname:///docs/0.3.1/api/java/com/datastrato/gravitino/dto/rel/partitions/Partitioning.html) |
+| Table bucketing | Equal to `CLUSTERED BY` in Apache Hive, Bucketing a.k.a (Clustering) is a technique to split the data into more manageable files/parts, (By specifying the number of buckets to create). The value of the bucketing column will be hashed by a user-defined number into buckets. | [Distribution](pathname:///docs/0.3.1/api/java/com/datastrato/gravitino/rel/expressions/distributions/Distribution.html) |
+| Table sort ordering | Equal to `SORTED BY` in Apache Hive, sort ordering is a method to sort the data in specific ways such as by a column or a function, and then store table data. it will highly improve the query performance under certain scenarios. | [SortOrder](pathname:///docs/0.3.1/api/java/com/datastrato/gravitino/rel/expressions/sorts/SortOrder.html) |
+| Table indexing | Equal to `KEY/INDEX` in MySQL , unique key enforces uniqueness of values in one or more columns within a table. It ensures that no two rows have identical values in specified columns, thereby facilitating data integrity and enabling efficient data retrieval and manipulation operations. | [Index](pathname:///docs/0.4.0/api/java/com/datastrato/gravitino/rel/indexes/Index.html) |
-For more information, please see the related document on [partitioning, bucketing, and sorting](table-partitioning-bucketing-sort-order.md).
+For more information, please see the related document on [partitioning, bucketing, sorting, and indexing](table-partitioning-bucketing-sort-order-indexes.md).
:::note
The code above is an example of creating a Hive table. For other catalogs, the code is similar, but the supported column type, and table properties may be different. For more details, please refer to the related doc.
diff --git a/docs/open-api/indexes.yaml b/docs/open-api/indexes.yaml
new file mode 100644
index 0000000000..30cfd6ed9b
--- /dev/null
+++ b/docs/open-api/indexes.yaml
@@ -0,0 +1,31 @@
+#
+# Copyright 2024 Datastrato Pvt Ltd.
+# This software is licensed under the Apache License version 2.
+#
+
+---
+
+components:
+ schemas:
+ IndexesSpec:
+ type: array
+ items:
+ $ref: "#/components/schemas/IndexSpec"
+
+ IndexSpec:
+ type: object
+ required:
+ - indexType
+ - fieldNames
+ properties:
+ indexType:
+ type: string
+ enum:
+ - "primary_key"
+ - "unique_key"
+ name:
+ type: string
+ description: The name of the index
+ nullable: true
+ fieldNames:
+ $ref: "./tables.yaml#/components/schemas/FieldNames"
diff --git a/docs/open-api/tables.yaml b/docs/open-api/tables.yaml
index 5958d4a9dc..62f55a4eb9 100644
--- a/docs/open-api/tables.yaml
+++ b/docs/open-api/tables.yaml
@@ -39,6 +39,10 @@ paths:
examples:
HiveTableCreate:
$ref: "#/components/examples/HiveTableCreate"
+ MysqlTableCreate:
+ $ref: "#/components/examples/MysqlTableCreate"
+ PostgresqlTableCreate:
+ $ref: "#/components/examples/PostgresqlTableCreate"
responses:
"200":
$ref: "#/components/responses/TableResponse"
@@ -190,6 +194,13 @@ components:
default: [ ]
items:
$ref: "./partitioning.yaml#/components/schemas/PartitioningSpec"
+ indexes:
+ type: array
+ description: Indexes of the table
+ nullable: true
+ default: [ ]
+ items:
+ $ref: "./indexes.yaml#/components/schemas/IndexSpec"
Table:
type: object
@@ -236,6 +247,13 @@ components:
default: [ ]
items:
$ref: "./partitioning.yaml#/components/schemas/PartitioningSpec"
+ indexes:
+ type: array
+ description: Indexes of the table
+ nullable: true
+ default: [ ]
+ items:
+ $ref: "./indexes.yaml#/components/schemas/IndexSpec"
Distribution:
type: object
@@ -322,6 +340,11 @@ components:
description: Whether the column is nullable
nullable: true
default: true
+ autoIncrement:
+ type: boolean
+ description: Whether the column is auto increment
+ nullable: true
+ default: false
TableUpdatesRequest:
type: object
@@ -667,6 +690,10 @@ components:
examples:
TableResponse:
$ref: "#/components/examples/TableResponse"
+ MysqlTableResponse:
+ $ref: "#/components/examples/MysqlTableResponse"
+ PostgresqlTableResponse:
+ $ref: "#/components/examples/PostgresqlTableResponse"
examples:
TableListResponse:
@@ -693,7 +720,8 @@ components:
"name": "id",
"type": "integer",
"comment": "id column comment",
- "nullable": true
+ "nullable": true,
+ "autoIncrement": false
},
{
"name": "name",
@@ -742,9 +770,115 @@ components:
],
"properties": {
"format": "ORC"
+ },
+ indexes:[ ]
+ }
+
+ MysqlTableCreate:
+ value: {
+ "name": "my_mysql_table",
+ "comment": "This is my MySQL table",
+ "columns": [
+ {
+ "name": "id",
+ "type": "int",
+ "comment": "id column comment",
+ "nullable": false,
+ "autoIncrement": true
+ },
+ {
+ "name": "name",
+ "type": "string",
+ "comment": "name column comment",
+ "nullable": true
+ },
+ {
+ "name": "age",
+ "type": "int",
+ "comment": "age column comment",
+ "nullable": true
+ },
+ {
+ "name": "dt",
+ "type": "date",
+ "comment": "dt column comment",
+ "nullable": true
+ }
+ ],
+ "indexes": [
+ {
+ "indexType": "primary_key",
+ "name": "PRIMARY",
+ "fieldNames": [["id"]]
+ },
+ {
+ "indexType": "unique_key",
+ "name": "uk_1",
+ "fieldNames": [["name"]]
+ },
+ {
+ "indexType": "unique_key",
+ "name": "uk_2",
+ "fieldNames": [["name"] ,["age"] ,["dt"]]
+ }
+ ],
+ "properties": {
+ "engine": "InnoDB",
+ "auto-increment-offset": "1"
}
}
+ PostgresqlTableCreate:
+ value: {
+ "name": "my_postgresql_table",
+ "comment": "This is my PostgreSQL table",
+ "columns": [
+ {
+ "name": "id",
+ "type": "int",
+ "comment": "id column comment",
+ "nullable": false,
+ "autoIncrement": true
+ },
+ {
+ "name": "name",
+ "type": "string",
+ "comment": "name column comment",
+ "nullable": true
+ },
+ {
+ "name": "age",
+ "type": "int",
+ "comment": "age column comment",
+ "nullable": true
+ },
+ {
+ "name": "dt",
+ "type": "date",
+ "comment": "dt column comment",
+ "nullable": true
+ }
+ ],
+ "indexes": [
+ {
+ "indexType": "primary_key",
+ "name": "PRIMARY",
+ "fieldNames": [["id"]]
+ },
+ {
+ "indexType": "unique_key",
+ "name": "uk_1",
+ "fieldNames": [["name"]]
+ },
+ {
+ "indexType": "unique_key",
+ "name": "uk_2",
+ "fieldNames": [["name"] ,["age"] ,["dt"]]
+ }
+ ],
+ "properties": { }
+ }
+
TableResponse:
value: {
"code": 0,
@@ -756,7 +890,8 @@ components:
"name": "id",
"type": "integer",
"comment": "id column comment",
- "nullable": true
+ "nullable": true,
+ "autoIncrement": false
},
{
"name": "name",
@@ -821,6 +956,132 @@ components:
"dt"
]
}
+ ],
+ "indexes": [ ]
+ }
+ }
+
+ MysqlTableResponse:
+ value: {
+ "code": 0,
+ "table": {
+ "name": "my_mysql_table",
+ "comment": "This is my MySQL table",
+ "columns": [
+ {
+ "name": "id",
+ "type": "integer",
+ "comment": "id column comment",
+ "nullable": true,
+ "autoIncrement": 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
+ }
+ ],
+ "properties": {
+ "engine": "InnoDB",
+ "auto-increment-offset": "1",
+ },
+ "audit": {
+ "creator": "gravitino",
+ "createTime": "2023-12-08T11:07:46.938Z"
+ },
+ "distribution": null,
+ "sortOrders": [ ],
+ "partitioning": [ ],
+ "indexes": [
+ {
+ "indexType": "primary_key",
+ "name": "PRIMARY",
+ "fieldNames": [["id"]]
+ },
+ {
+ "indexType": "unique_key",
+ "name": "uk_1",
+ "fieldNames": [["name"]]
+ },
+ {
+ "indexType": "unique_key",
+ "name": "uk_2",
+ "fieldNames": [["name"] ,["age"] ,["dt"]]
+ }
+ ]
+ }
+ }
+
+ PostgresqlTableResponse:
+ value: {
+ "code": 0,
+ "table": {
+ "name": "my_postgresql_table",
+ "comment": "This is my PostgreSQL table",
+ "columns": [
+ {
+ "name": "id",
+ "type": "integer",
+ "comment": "id column comment",
+ "nullable": true,
+ "autoIncrement": 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
+ }
+ ],
+ "properties": { },
+ "audit": {
+ "creator": "gravitino",
+ "createTime": "2023-12-08T11:07:46.938Z"
+ },
+ "distribution": null,
+ "sortOrders": [ ],
+ "partitioning": [ ],
+ "indexes": [
+ {
+ "indexType": "primary_key",
+ "name": "PRIMARY",
+ "fieldNames": [["id"]]
+ },
+ {
+ "indexType": "unique_key",
+ "name": "uk_1",
+ "fieldNames": [["name"]]
+ },
+ {
+ "indexType": "unique_key",
+ "name": "uk_2",
+ "fieldNames": [["name"] ,["age"] ,["dt"]]
+ }
]
}
}
diff --git a/docs/table-partitioning-bucketing-sort-order.md b/docs/table-partitioning-bucketing-sort-order-indexes.md
similarity index 75%
rename from docs/table-partitioning-bucketing-sort-order.md
rename to docs/table-partitioning-bucketing-sort-order-indexes.md
index ae3496cb81..2d76543e6a 100644
--- a/docs/table-partitioning-bucketing-sort-order.md
+++ b/docs/table-partitioning-bucketing-sort-order-indexes.md
@@ -1,9 +1,12 @@
---
title: "Table partitioning, bucketing and sort ordering"
-slug: /table-partitioning-bucketing-sort-order
+slug: /table-partitioning-bucketing-sort-order-indexes
date: 2023-12-25
keyword: Table Partition Bucket Distribute Sort By
license: Copyright 2023 Datastrato Pvt Ltd. This software is licensed under the Apache License version 2.
+last_update:
+ date: 2024-02-02
+ author: Clearvive
---
import Tabs from '@theme/Tabs';
@@ -285,3 +288,116 @@ tableCatalog.createTable(
</TabItem>
</Tabs>
+
+## Indexing
+
+To define an indexed table, you should utilize the following three components to construct a valid indexed table.
+
+- IndexType. Represents the type of index, such as primary key or unique key.
+
+| IndexType | Description | JSON | Java |
+|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|---------------------------|
+| PRIMARY_KEY | The PRIMARY KEY is a column or set of columns that uniquely identifies each row in a table. It enforces uniqueness and ensures that no two rows have the same values in the specified columns. Additionally, the PRIMARY KEY constraint automatically creates a unique index on the specified columns. | `PRIMARY_KEY` | `IndexType.PRIMARY_KEY` |
+| UNIQUE_KEY | The UNIQUE KEY constraint ensures that all values in a specified column or set of columns are unique across the entire table. Unlike the PRIMARY KEY constraint, a table can have multiple UNIQUE KEY constraints, allowing for unique values in multiple columns or sets of columns. | `UNIQUE_KEY` | `IndexType.UNIQUE_KEY` |
+
+- Name. It defines the name of the index.
+
+- FieldNames. It defines which table fields Gravitino uses to index the table.
+
+<Tabs>
+<TabItem value="Json" label="Json">
+
+```json
+ {
+ "indexType": "PRIMARY_KEY",
+ "name": "PRIMARY",
+ "fieldNames": [["col_1"],["col_2"]]
+}
+```
+
+</TabItem>
+<TabItem value="java" label="Java">
+
+```java
+Indexes.of(IndexType.PRIMARY_KEY, "PRIMARY", new String[][]{{"col_1"}, {"col_2"}});
+```
+
+</TabItem>
+</Tabs>
+
+The following is an example of creating a index table:
+
+<Tabs>
+<TabItem value="shell" label="Shell">
+
+```shell
+curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
+-H "Content-Type: application/json" -d '{
+ "name": "table",
+ "columns": [
+ {
+ "name": "id",
+ "type": "integer",
+ "nullable": true,
+ "comment": "Id of the user"
+ },
+ {
+ "name": "name",
+ "type": "varchar(2000)",
+ "nullable": true,
+ "comment": "Name of the user"
+ },
+ {
+ "name": "age",
+ "type": "short",
+ "nullable": true,
+ "comment": "Age of the user"
+ },
+ {
+ "name": "score",
+ "type": "double",
+ "nullable": true,
+ "comment": "Score of the user"
+ }
+ ],
+ "comment": "Create a new Table",
+ "indexes": [
+ {
+ "indexType": "PRIMARY_KEY",
+ "name": "PRIMARY",
+ "fieldNames": [["id"]]
+ },
+ {
+ "indexType": "UNIQUE_KEY",
+ "name": "name_age_score_uk",
+ "fieldNames": [["name"],["age"],["score]]
+ }
+ ]
+}' http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/tables
+```
+
+</TabItem>
+<TabItem value="java" label="Java">
+
+```java
+tableCatalog.createTable(
+ NameIdentifier.of("metalake", "hive_catalog", "schema", "table"),
+ new Column[] {
+ Column.of("id", Types.IntegerType.get(), "Id of the user", false, true, null),
+ Column.of("name", Types.VarCharType.of(1000), "Name of the user", true, false, null),
+ Column.of("age", Types.ShortType.get(), "Age of the user", true, false, null),
+ Column.of("score", Types.DoubleType.get(), "Score of the user", true, false, null)
+ },
+ "Create a new Table",
+ tablePropertiesMap,
+ Transforms.EMPTY_TRANSFORM,
+ Distributions.NONE,
+ new SortOrder[0],
+ new Index[] {
+ Indexes.of(IndexType.PRIMARY_KEY, "PRIMARY", new String[][]{{"id"}}),
+ Indexes.of(IndexType.UNIQUE_KEY, "name_age_score_uk", new String[][]{{"name"}, {"age"}, {"score"}})
+ });
+```
+
+</TabItem>
+</Tabs>
\ No newline at end of file