Skip to content

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

[#1651][#1274] docs: Add example for complex data type of column (#1858)

mchadesce33e0e3b3e0
diff --git a/docs/manage-metadata-using-gravitino.md b/docs/manage-metadata-using-gravitino.md
index 0e1245e6e7..575b2f8878 100644
--- a/docs/manage-metadata-using-gravitino.md
+++ b/docs/manage-metadata-using-gravitino.md
@@ -609,22 +609,97 @@ You can create a table by sending a `POST` request to the `/api/metalakes/{metal
```shell
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
- "name": "table",
+ "name": "my_table",
+ "comment": "This is my table",
"columns": [
{
"name": "id",
"type": "integer",
- "nullable": true,
- "comment": "Id of the user"
+ "comment": "id column comment",
+ "nullable": true
},
{
"name": "name",
- "type": "varchar(2000)",
- "nullable": true,
- "comment": "Name of the user"
+ "type": "string",
+ "comment": "name column comment",
+ "nullable": true
+ },
+ {
+ "name": "age",
+ "type": "integer",
+ "comment": "age column comment",
+ "nullable": true
+ },
+ {
+ "name": "info",
+ "type": {
+ "type": "struct",
+ "fields": [
+ {
+ "name": "position",
+ "type": "string",
+ "nullable": true,
+ "comment": "position field comment"
+ },
+ {
+ "name": "contact",
+ "type": {
+ "type": "list",
+ "elementType": "integer",
+ "containsNull": false
+ },
+ "nullable": true,
+ "comment": "contact field comment"
+ },
+ {
+ "name": "rating",
+ "type": {
+ "type": "map",
+ "keyType": "string",
+ "valueType": "integer",
+ "valueContainsNull": false
+ },
+ "nullable": true,
+ "comment": "rating field comment"
+ }
+ ]
+ },
+ "comment": "info column comment",
+ "nullable": true
+ },
+ {
+ "name": "dt",
+ "type": "date",
+ "comment": "dt column comment",
+ "nullable": true
+ }
+ ],
+ "partitioning": [
+ {
+ "strategy": "identity",
+ "fieldName": [ "dt" ]
+ }
+ ],
+ "distribution": {
+ "strategy": "hash",
+ "number": 32,
+ "funcArgs": [
+ {
+ "type": "field",
+ "fieldName": [ "id" ]
+ }
+ ]
+ },
+ "sortOrders": [
+ {
+ "sortTerm": {
+ "type": "field",
+ "fieldName": [ "age" ]
+ },
+ "direction": "asc",
+ "nullOrdering": "nulls_first"
}
],
- "comment": "Create a new Table",
"properties": {
"format": "ORC"
}
@@ -711,8 +786,7 @@ The following types that Gravitino supports:
| List | `Types.ListType.of(elementType, elementNullable)` | `{"type": "list", "containsNull": JSON Boolean, "elementType": type JSON}` | List type, indicate a list of elements with the same type |
| Map | `Types.MapType.of(keyType, valueType)` | `{"type": "map", "keyType": type JSON, "valueType": type JSON, "valueContainsNull": JSON Boolean}` | Map type, indicate a map of key-value pairs |
| Struct | `Types.StructType.of([Types.StructType.Field.of(name, type, nullable)])` | `{"type": "struct", "fields": [JSON StructField, {"name": string, "type": type JSON, "nullable": JSON Boolean, "comment": string}]}` | Struct type, indicate a struct of fields |
-| Union | `Types.UnionType.of([type1, type2, ...])` | `{"type": "union", "types": [type JSON, ...]}` | Union type, indicates a union of types
-
+| Union | `Types.UnionType.of([type1, type2, ...])` | `{"type": "union", "types": [type JSON, ...]}` | Union type, indicates a union of types |
The related java doc is [here](pathname:///docs/0.3.1/api/java/com/datastrato/gravitino/rel/types/Type.html).
diff --git a/docs/open-api/datatype.yaml b/docs/open-api/datatype.yaml
index 2a01972bee..c1afca9a35 100644
--- a/docs/open-api/datatype.yaml
+++ b/docs/open-api/datatype.yaml
@@ -53,6 +53,13 @@ components:
type: array
items:
$ref: "#/components/schemas/DataType"
+ example: {
+ "type": "union",
+ "types": [
+ "string",
+ "integer"
+ ]
+ }
MapType:
type: object
@@ -74,6 +81,12 @@ components:
description: Whether the value of the map contains null values
nullable: true
default: true
+ example: {
+ "type": "map",
+ "keyType": "string",
+ "valueType": "integer",
+ "valueContainsNull": false
+ }
ListType:
type: object
@@ -92,6 +105,11 @@ components:
default: true
elementType:
$ref: "#/components/schemas/DataType"
+ example: {
+ "type": "list",
+ "elementType": "integer",
+ "containsNull": false
+ }
StructType:
type: object
@@ -107,6 +125,23 @@ components:
type: array
items:
$ref: "#/components/schemas/StructField"
+ example: {
+ "type": "struct",
+ "fields": [
+ {
+ "name": "id",
+ "type": "integer",
+ "nullable": false,
+ "comment": "The id of the user"
+ },
+ {
+ "name": "name",
+ "type": "string",
+ "nullable": false,
+ "comment": "The name of the user"
+ }
+ ]
+ }
StructField:
type: object