World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#15328] fix: Report missing function signatures and align catalog API docs (#15329)
Qi Yubff8a2fa05e0
diff --git a/common/src/main/java/org/apache/gravitino/dto/requests/FunctionUpdateRequest.java b/common/src/main/java/org/apache/gravitino/dto/requests/FunctionUpdateRequest.javaindex c1d3618831..d51c9cabf8 100644--- a/common/src/main/java/org/apache/gravitino/dto/requests/FunctionUpdateRequest.java+++ b/common/src/main/java/org/apache/gravitino/dto/requests/FunctionUpdateRequest.java@@ -81,7 +81,7 @@ public interface FunctionUpdateRequest extends RESTRequest {@Overridepublic void validate() throws IllegalArgumentException {- // newComment can be null or empty to clear the comment+ // FunctionChange.updateComment requires a nonblank value when converting this request.}}diff --git a/core/src/main/java/org/apache/gravitino/catalog/ManagedFunctionOperations.java b/core/src/main/java/org/apache/gravitino/catalog/ManagedFunctionOperations.javaindex 30418424ba..0c16fca645 100644--- a/core/src/main/java/org/apache/gravitino/catalog/ManagedFunctionOperations.java+++ b/core/src/main/java/org/apache/gravitino/catalog/ManagedFunctionOperations.java@@ -432,22 +432,14 @@ public class ManagedFunctionOperations implements FunctionCatalog {*/private void validateRemoveDefinition(List<FunctionDefinition> definitions, FunctionParam[] paramsToRemove) {- if (definitions.size() == 1) {+ if (definitions.stream().noneMatch(def -> parametersMatch(def.parameters(), paramsToRemove))) {throw new IllegalArgumentException(- "Cannot remove the only definition. Use dropFunction to remove the entire function.");- }-- boolean found = false;- for (FunctionDefinition def : definitions) {- if (parametersMatch(def.parameters(), paramsToRemove)) {- found = true;- break;- }+ "Cannot remove definition: no definition found with the specified parameters");}- if (!found) {+ if (definitions.size() == 1) {throw new IllegalArgumentException(- "Cannot remove definition: no definition found with the specified parameters");+ "Cannot remove the only definition. Use dropFunction to remove the entire function.");}}diff --git a/core/src/test/java/org/apache/gravitino/catalog/TestManagedFunctionOperations.java b/core/src/test/java/org/apache/gravitino/catalog/TestManagedFunctionOperations.javaindex 8d8f06cfdc..19651c1854 100644--- a/core/src/test/java/org/apache/gravitino/catalog/TestManagedFunctionOperations.java+++ b/core/src/test/java/org/apache/gravitino/catalog/TestManagedFunctionOperations.java@@ -505,10 +505,15 @@ public class TestManagedFunctionOperations {functionOperations.registerFunction(funcIdent, "Test function", FunctionType.SCALAR, true, definitions);- // Try to remove the only definition - should fail- Assertions.assertThrows(- IllegalArgumentException.class,- () -> functionOperations.alterFunction(funcIdent, FunctionChange.removeDefinition(params)));+ IllegalArgumentException error =+ Assertions.assertThrows(+ IllegalArgumentException.class,+ () ->+ functionOperations.alterFunction(+ funcIdent, FunctionChange.removeDefinition(params)));+ Assertions.assertEquals(+ "Cannot remove the only definition. Use dropFunction to remove the entire function.",+ error.getMessage());}@Test@@ -525,11 +530,15 @@ public class TestManagedFunctionOperations {FunctionParam[] nonExistingParams =new FunctionParam[] {FunctionParams.of("x", Types.StringType.get())};- Assertions.assertThrows(- IllegalArgumentException.class,- () ->- functionOperations.alterFunction(- funcIdent, FunctionChange.removeDefinition(nonExistingParams)));+ IllegalArgumentException error =+ Assertions.assertThrows(+ IllegalArgumentException.class,+ () ->+ functionOperations.alterFunction(+ funcIdent, FunctionChange.removeDefinition(nonExistingParams)));+ Assertions.assertEquals(+ "Cannot remove definition: no definition found with the specified parameters",+ error.getMessage());}@Testdiff --git a/docs/apache-hive-catalog.md b/docs/apache-hive-catalog.mdindex e1dd0dccc5..8d6cfa2191 100644--- a/docs/apache-hive-catalog.md+++ b/docs/apache-hive-catalog.md@@ -153,8 +153,11 @@ The `fieldName` specified in the `distribution` and `sortOrders` attribute must### 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 Gravitino.+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](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+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 ||-----------------------------|---------------------|@@ -165,10 +168,10 @@ The following table lists the data types mapped from the Hive catalog to Graviti| `bigint` | `long` || `float` | `float` || `double`/`double precision` | `double` |-| `decimal` | `decimal` |+| `decimal(p,s)` | `decimal(p,s)` || `string` | `string` |-| `char` | `char` |-| `varchar` | `varchar` |+| `char(n)` | `char(n)` |+| `varchar(n)` | `varchar(n)` || `timestamp` | `timestamp` || `date` | `date` || `interval_year_month` | `interval_year` |@@ -179,14 +182,20 @@ The following table lists the data types mapped from the Hive catalog to Graviti| `struct` | `struct` || `uniontype` | `union` |-:::info-1. The data types other than listed above are mapped to Gravitino **[External Type](./tables-and-views.md#external-type)** that represents an unresolvable data type from the Hive catalog.-2. Using the `struct` data type with field comments will throw an error, as it does not work for Hive tables (see [HIVE-26593](https://issues.apache.org/jira/browse/HIVE-26593)).-:::+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](./tables-and-views.md#external-type). Table creation requires a mapped Gravitino type.+Hive also rejects comments on nested struct fields ([HIVE-26593](https://issues.apache.org/jira/browse/HIVE-26593)).### Table Properties-Table properties supply or set metadata for the underlying Hive tables.+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.:::notediff --git a/docs/lakehouse-hudi-catalog.md b/docs/lakehouse-hudi-catalog.mdindex 291f3a0f91..5e2b7cc98c 100644--- a/docs/lakehouse-hudi-catalog.md+++ b/docs/lakehouse-hudi-catalog.md@@ -86,6 +86,11 @@ Refer to [Manage Catalogs and Schemas](./manage-catalogs-and-schemas.md#catalog-- Only support read operations: listSchema, loadSchema, and schemaExists.+When a Hive catalog and a Hudi catalog share an HMS, use one Gravitino catalog to manage each+schema. A schema registered through the Hive catalog can still appear in Hudi listings, but loading+it or one of its tables through the Hudi catalog can fail with HTTP 501 because its external+identifier already belongs to the Hive registration.+### Schema Properties- The `Location` is an optional property that shows the storage path to the Hudi database@@ -123,7 +128,8 @@ Refer to [Manage Catalogs and Schemas](./manage-catalogs-and-schemas.md#schema-o### Table Column Types-The following table shows the mapping between Gravitino and [Apache Hudi column types](https://hudi.apache.org/docs/sql_ddl#supported-types):+The table maps the Gravitino type names returned by the REST API to+[Apache Hudi SQL types](https://hudi.apache.org/docs/sql_ddl#supported-types).| Gravitino Type | Apache Hudi Type ||----------------|------------------|@@ -135,12 +141,18 @@ The following table shows the mapping between Gravitino and [Apache Hudi column| `float` | `float` || `double` | `double` || `string` | `string` |-| `decimal` | `decimal` |+| `decimal(p,s)` | `decimal(p,s)` || `binary` | `bytes` |-| `array` | `array` |+| `list` | `array` || `map` | `map` || `struct` | `struct` |+The HMS backend reads column types through the Hive converter, so tables can also expose+`byte`, `short`, `varchar(n)`, and `char(n)`. For `decimal(p,s)`, precision ranges from 1 to 38+and scale from 0 through precision. An HMS `timestamp` is returned without a time zone.+See the [Hive type mapping](./apache-hive-catalog.md#table-column-types) for length limits and the+types available when creating tables through the Hive catalog.+### Table OperationsOnly support read operations: listTable, loadTable, and tableExists.diff --git a/docs/open-api/indexes.yaml b/docs/open-api/indexes.yamlindex ba594994df..72c5f038b2 100644--- a/docs/open-api/indexes.yaml+++ b/docs/open-api/indexes.yaml@@ -32,24 +32,42 @@ components:properties:indexType:type: string+ description: >-+ Responses use the uppercase names below. Requests accept index types case-insensitively.+ Support depends on the catalog. For example, MySQL supports PRIMARY_KEY and UNIQUE_KEY,+ and the DATA_SKIPPING_* types describe ClickHouse indexes.enum:- - "primary_key"- - "unique_key"- - "data_skipping_minmax"- - "data_skipping_bloom_filter"- - "data_skipping_set"- - "data_skipping_ngrambfv1"- - "data_skipping_tokenbfv1"- - "data_skipping_annoy"- - "data_skipping_usearch"- - "data_skipping_text"- - "data_skipping_vector_similarity"+ - "PRIMARY_KEY"+ - "UNIQUE_KEY"+ - "SCALAR"+ - "BTREE"+ - "BITMAP"+ - "LABEL_LIST"+ - "INVERTED"+ - "VECTOR"+ - "IVF_FLAT"+ - "IVF_SQ"+ - "IVF_PQ"+ - "IVF_HNSW_SQ"+ - "IVF_HNSW_PQ"+ - "DATA_SKIPPING_MINMAX"+ - "DATA_SKIPPING_BLOOM_FILTER"+ - "DATA_SKIPPING_SET"+ - "DATA_SKIPPING_NGRAMBFV1"+ - "DATA_SKIPPING_TOKENBFV1"+ - "DATA_SKIPPING_TEXT"+ - "DATA_SKIPPING_VECTOR_SIMILARITY"+ - "DATA_SKIPPING_ANNOY"+ - "DATA_SKIPPING_USEARCH"name:type: stringdescription: The name of the indexnullable: truefieldNames:- $ref: "./tables.yaml#/components/schemas/FieldNames"+ type: array+ minItems: 1+ items:+ $ref: "./tables.yaml#/components/schemas/FieldName"properties:type: objectadditionalProperties:diff --git a/docs/open-api/tables.yaml b/docs/open-api/tables.yamlindex 453c5a0724..5ca09791e4 100644--- a/docs/open-api/tables.yaml+++ b/docs/open-api/tables.yaml@@ -511,6 +511,8 @@ components:- $ref: "#/components/schemas/UpdateTableColumnNullabilityRequest"- $ref: "#/components/schemas/UpdateTableColumnDefaultValueRequest"- $ref: "#/components/schemas/DeleteTableColumnRequest"+ - $ref: "#/components/schemas/AddTableIndexRequest"+ - $ref: "#/components/schemas/DeleteTableIndexRequest"discriminator:propertyName: "@type"mapping:@@ -526,6 +528,8 @@ components:updateColumnNullability: "#/components/schemas/UpdateTableColumnNullabilityRequest"updateColumnDefaultValue: "#/components/schemas/UpdateTableColumnDefaultValueRequest"deleteColumn: "#/components/schemas/DeleteTableColumnRequest"+ addTableIndex: "#/components/schemas/AddTableIndexRequest"+ deleteTableIndex: "#/components/schemas/DeleteTableIndexRequest"RenameTableRequest:type: object@@ -827,6 +831,46 @@ components:"ifExists": true}+ AddTableIndexRequest:+ type: object+ required:+ - "@type"+ - index+ properties:+ "@type":+ type: string+ enum:+ - "addTableIndex"+ index:+ $ref: "./indexes.yaml#/components/schemas/IndexSpec"+ example:+ "@type": addTableIndex+ index:+ indexType: UNIQUE_KEY+ name: email_uk+ fieldNames: [[email]]++ DeleteTableIndexRequest:+ type: object+ required:+ - "@type"+ - name+ properties:+ "@type":+ type: string+ enum:+ - "deleteTableIndex"+ name:+ type: string+ description: The name of the index to delete+ ifExists:+ type: boolean+ description: If true, ignore a missing index+ default: false+ example:+ "@type": deleteTableIndex+ name: email_uk+ ifExists: trueColumnPosition:oneOf:@@ -939,18 +983,16 @@ components:{"name": "position","type": "string",- "nullable": true,- "comment": "position field comment"+ "nullable": true},{"name": "contact","type": {"type": "list","elementType": "integer",- "containsNull": false+ "containsNull": true},- "nullable": true,- "comment": "contact field comment"+ "nullable": true},{"name": "rating",@@ -958,10 +1000,9 @@ components:"type": "map","keyType": "string","valueType": "integer",- "valueContainsNull": false+ "valueContainsNull": true},- "nullable": true,- "comment": "rating field comment"+ "nullable": true}]},@@ -1004,7 +1045,7 @@ components:"properties": {"format": "ORC"},- indexes:[ ]+ "indexes": [ ]}MysqlTableCreate:@@ -1045,17 +1086,17 @@ components:],"indexes": [{- "indexType": "primary_key",+ "indexType": "PRIMARY_KEY","name": "PRIMARY","fieldNames": [["id"]]},{- "indexType": "unique_key",+ "indexType": "UNIQUE_KEY","name": "uk_1","fieldNames": [["name"]]},{- "indexType": "unique_key",+ "indexType": "UNIQUE_KEY","name": "uk_2","fieldNames": [["name"] ,["age"] ,["dt"]]}@@ -1099,17 +1140,17 @@ components:],"indexes": [{- "indexType": "primary_key",+ "indexType": "PRIMARY_KEY","name": "PRIMARY","fieldNames": [["id"]]},{- "indexType": "unique_key",+ "indexType": "UNIQUE_KEY","name": "uk_1","fieldNames": [["name"]]},{- "indexType": "unique_key",+ "indexType": "UNIQUE_KEY","name": "uk_2","fieldNames": [["name"] ,["age"] ,["dt"]]}@@ -1293,17 +1334,17 @@ components:"partitioning": [ ],"indexes": [{- "indexType": "primary_key",+ "indexType": "PRIMARY_KEY","name": "PRIMARY","fieldNames": [["id"]]},{- "indexType": "unique_key",+ "indexType": "UNIQUE_KEY","name": "uk_1","fieldNames": [["name"]]},{- "indexType": "unique_key",+ "indexType": "UNIQUE_KEY","name": "uk_2","fieldNames": [["name"] ,["age"] ,["dt"]]}@@ -1354,17 +1395,17 @@ components:"partitioning": [ ],"indexes": [{- "indexType": "primary_key",+ "indexType": "PRIMARY_KEY","name": "PRIMARY","fieldNames": [["id"]]},{- "indexType": "unique_key",+ "indexType": "UNIQUE_KEY","name": "uk_1","fieldNames": [["name"]]},{- "indexType": "unique_key",+ "indexType": "UNIQUE_KEY","name": "uk_2","fieldNames": [["name"] ,["age"] ,["dt"]]}