Register function
POST/metalakes/:metalake/catalogs/:catalog/schemas/:schema/functions
Registers a function in the schema with one or more definitions, each with its parameters, return type or columns and implementations, and returns the registered function.
Sign in with a bearer token or a local user's password; see Authentication.
Request
Path Parameters
The name of the metalake
The name of the catalog
The name of the schema
- application/json
Body
Array [
Array [
- WritablePrimitiveType
- WritableStructType
- WritableListType
- WritableMapType
- WritableUnionType
- WritableExternalType
Array [
- MOD1
- MOD2
]
- MOD1
- MOD2
- MOD1
- MOD2
- MOD1
- MOD2
Array [
- MOD1
- MOD2
]
- Literal
- Field
- Function
- PrimitiveType
- StructType
- ListType
- MapType
- UnionType
- UnparsedType
- ExternalType
Array [
- MOD1
- MOD2
]
- MOD1
- MOD2
- MOD1
- MOD2
- MOD1
- MOD2
Array [
- MOD1
- MOD2
]
]
- WritablePrimitiveType
- WritableStructType
- WritableListType
- WritableMapType
- WritableUnionType
- WritableExternalType
Array [
- MOD1
- MOD2
]
- MOD1
- MOD2
- MOD1
- MOD2
- MOD1
- MOD2
Array [
- MOD1
- MOD2
]
Array [
- WritablePrimitiveType
- WritableStructType
- WritableListType
- WritableMapType
- WritableUnionType
- WritableExternalType
Array [
- MOD1
- MOD2
]
- MOD1
- MOD2
- MOD1
- MOD2
- MOD1
- MOD2
Array [
- MOD1
- MOD2
]
]
Array [
- SQLImpl
- JavaImpl
- PythonImpl
]
]
The name of the function. Cannot be empty.
Possible values: [scalar, aggregate, table]
The type of the function. Responses return the value in lowercase; requests accept any case.
Whether the function is deterministic
The comment of the function
definitions
object[]
required
Possible values: >= 1
The function definitions. Must contain at least one definition.
parameters
object[]
The parameters of the function definition
The name of the parameter
dataType
object
required
The data type of the parameter
oneOf
The canonical string form of a Gravitino-recognized primitive type. Parameters are validated by the server.
Possible values: [struct]
fields
object[]
required
The name of the struct field
type
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
Default value: true
Whether the struct field is nullable
The comment of the struct field
Possible values: [list]
Default value: true
Whether the list contains null values
elementType
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
Possible values: [map]
keyType
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
valueType
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
Default value: true
Whether the value of the map contains null values
Possible values: [union]
types
object[]
required
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
The explicit catalog- or engine-specific type form accepted when writing resolved metadata.
Possible values: [external]
Possible values: non-empty, Value must match regular expression .*\S.*
The non-blank string representation of this type in the catalog
The comment of the parameter
defaultValue
object
The default value expression of the parameter
oneOf
Possible values: [literal]
dataType
object
required
The general, read-compatible data type representation. UnparsedType preserves types that the current server cannot resolve when reading existing metadata. Endpoints that require resolved new metadata use WritableDataType instead.
oneOf
The string name of a primitive type, such as boolean, byte, byte unsigned, short, short unsigned, integer, integer unsigned, long, long unsigned, float, double, decimal(10,2), date, time(3), timestamp(3), timestamp_tz(3), string, char(10), varchar(10), interval_day, interval_year, uuid, fixed(16) or binary.
string
Possible values: [struct]
fields
object[]
required
The name of the struct field
type
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Default value: true
Whether the struct field is nullable
The comment of the struct field
Possible values: [list]
Default value: true
Whether the list contains null values
elementType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Possible values: [map]
keyType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
valueType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Default value: true
Whether the value of the map contains null values
Possible values: [union]
types
object[]
required
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Possible values: [unparsed]
The unparsed type
Possible values: [external]
The string representation of this type in the catalog
The string format of the literal value
Possible values: [field]
The name of the field, may be with multiple levels
Possible values: [function]
The name of the function
The arguments of the function
returnType
object
The return type of the function (for SCALAR and AGGREGATE functions)
oneOf
The canonical string form of a Gravitino-recognized primitive type. Parameters are validated by the server.
Possible values: [struct]
fields
object[]
required
The name of the struct field
type
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
Default value: true
Whether the struct field is nullable
The comment of the struct field
Possible values: [list]
Default value: true
Whether the list contains null values
elementType
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
Possible values: [map]
keyType
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
valueType
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
Default value: true
Whether the value of the map contains null values
Possible values: [union]
types
object[]
required
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
The explicit catalog- or engine-specific type form accepted when writing resolved metadata.
Possible values: [external]
Possible values: non-empty, Value must match regular expression .*\S.*
The non-blank string representation of this type in the catalog
returnColumns
object[]
nullable
The return columns of the function (for TABLE functions)
The name of the return column
dataType
object
required
The data type of the return column
oneOf
The canonical string form of a Gravitino-recognized primitive type. Parameters are validated by the server.
Possible values: [struct]
fields
object[]
required
The name of the struct field
type
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
Default value: true
Whether the struct field is nullable
The comment of the struct field
Possible values: [list]
Default value: true
Whether the list contains null values
elementType
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
Possible values: [map]
keyType
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
valueType
object
required
A nested data type, written in any form that WritableDataType accepts.
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
Default value: true
Whether the value of the map contains null values
Possible values: [union]
types
object[]
required
oneOf
A primitive type, as in WritablePrimitiveType
string
A struct, list, map, union or external type, as in WritableDataType
object
The explicit catalog- or engine-specific type form accepted when writing resolved metadata.
Possible values: [external]
Possible values: non-empty, Value must match regular expression .*\S.*
The non-blank string representation of this type in the catalog
The comment of the return column
impls
object[]
The implementations of the function definition
oneOf
Possible values: [SQL]
The implementation language. The server matches the value exactly, in uppercase, in both requests and responses.
Possible values: [SPARK, TRINO]
The runtime type of the implementation. Responses return the value in uppercase; requests accept any case.
The SQL expression
resources
object
External resources required by a function implementation
JAR file URIs
File URIs
Archive URIs
properties
object
nullable
Additional properties
Possible values: [JAVA]
The implementation language. The server matches the value exactly, in uppercase, in both requests and responses.
Possible values: [SPARK, TRINO]
The runtime type of the implementation. Responses return the value in uppercase; requests accept any case.
The fully qualified class name
resources
object
External resources required by a function implementation
JAR file URIs
File URIs
Archive URIs
properties
object
nullable
Additional properties
Possible values: [PYTHON]
The implementation language. The server matches the value exactly, in uppercase, in both requests and responses.
Possible values: [SPARK, TRINO]
The runtime type of the implementation. Responses return the value in uppercase; requests accept any case.
The Python handler function
The Python code block
resources
object
External resources required by a function implementation
JAR file URIs
File URIs
Archive URIs
properties
object
nullable
Additional properties
Responses
- 200
- 400
- 404
- 409
- 5xx
The function, with its type, determinism flag, comment, definitions with their implementations, and audit information.
- application/vnd.gravitino.v1+json
- Schema
- Example (from schema)
- FunctionResponse
Schema
Array [
Array [
- PrimitiveType
- StructType
- ListType
- MapType
- UnionType
- UnparsedType
- ExternalType
Array [
- MOD1
- MOD2
]
- MOD1
- MOD2
- MOD1
- MOD2
- MOD1
- MOD2
Array [
- MOD1
- MOD2
]
- Literal
- Field
- Function
- PrimitiveType
- StructType
- ListType
- MapType
- UnionType
- UnparsedType
- ExternalType
Array [
- MOD1
- MOD2
]
- MOD1
- MOD2
- MOD1
- MOD2
- MOD1
- MOD2
Array [
- MOD1
- MOD2
]
]
- PrimitiveType
- StructType
- ListType
- MapType
- UnionType
- UnparsedType
- ExternalType
Array [
- MOD1
- MOD2
]
- MOD1
- MOD2
- MOD1
- MOD2
- MOD1
- MOD2
Array [
- MOD1
- MOD2
]
Array [
- PrimitiveType
- StructType
- ListType
- MapType
- UnionType
- UnparsedType
- ExternalType
Array [
- MOD1
- MOD2
]
- MOD1
- MOD2
- MOD1
- MOD2
- MOD1
- MOD2
Array [
- MOD1
- MOD2
]
]
Array [
- SQLImpl
- JavaImpl
- PythonImpl
]
]
Possible values: [0]
Status code of the response
function
object
The name of the function
Possible values: [scalar, aggregate, table]
The type of the function. Responses return the value in lowercase; requests accept any case.
Whether the function is deterministic
The comment of the function
definitions
object[]
required
The definitions of the function
parameters
object[]
The parameters of the function definition
The name of the parameter
dataType
object
required
The general, read-compatible data type representation. UnparsedType preserves types that the current server cannot resolve when reading existing metadata. Endpoints that require resolved new metadata use WritableDataType instead.
oneOf
The string name of a primitive type, such as boolean, byte, byte unsigned, short, short unsigned, integer, integer unsigned, long, long unsigned, float, double, decimal(10,2), date, time(3), timestamp(3), timestamp_tz(3), string, char(10), varchar(10), interval_day, interval_year, uuid, fixed(16) or binary.
string
Possible values: [struct]
fields
object[]
required
The name of the struct field
type
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Default value: true
Whether the struct field is nullable
The comment of the struct field
Possible values: [list]
Default value: true
Whether the list contains null values
elementType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Possible values: [map]
keyType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
valueType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Default value: true
Whether the value of the map contains null values
Possible values: [union]
types
object[]
required
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Possible values: [unparsed]
The unparsed type
Possible values: [external]
The string representation of this type in the catalog
The comment of the parameter
defaultValue
object
The default value expression of the parameter
oneOf
Possible values: [literal]
dataType
object
required
The general, read-compatible data type representation. UnparsedType preserves types that the current server cannot resolve when reading existing metadata. Endpoints that require resolved new metadata use WritableDataType instead.
oneOf
The string name of a primitive type, such as boolean, byte, byte unsigned, short, short unsigned, integer, integer unsigned, long, long unsigned, float, double, decimal(10,2), date, time(3), timestamp(3), timestamp_tz(3), string, char(10), varchar(10), interval_day, interval_year, uuid, fixed(16) or binary.
string
Possible values: [struct]
fields
object[]
required
The name of the struct field
type
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Default value: true
Whether the struct field is nullable
The comment of the struct field
Possible values: [list]
Default value: true
Whether the list contains null values
elementType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Possible values: [map]
keyType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
valueType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Default value: true
Whether the value of the map contains null values
Possible values: [union]
types
object[]
required
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Possible values: [unparsed]
The unparsed type
Possible values: [external]
The string representation of this type in the catalog
The string format of the literal value
Possible values: [field]
The name of the field, may be with multiple levels
Possible values: [function]
The name of the function
The arguments of the function
returnType
object
The general, read-compatible data type representation. UnparsedType preserves types that the current server cannot resolve when reading existing metadata. Endpoints that require resolved new metadata use WritableDataType instead.
oneOf
The string name of a primitive type, such as boolean, byte, byte unsigned, short, short unsigned, integer, integer unsigned, long, long unsigned, float, double, decimal(10,2), date, time(3), timestamp(3), timestamp_tz(3), string, char(10), varchar(10), interval_day, interval_year, uuid, fixed(16) or binary.
string
Possible values: [struct]
fields
object[]
required
The name of the struct field
type
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Default value: true
Whether the struct field is nullable
The comment of the struct field
Possible values: [list]
Default value: true
Whether the list contains null values
elementType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Possible values: [map]
keyType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
valueType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Default value: true
Whether the value of the map contains null values
Possible values: [union]
types
object[]
required
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Possible values: [unparsed]
The unparsed type
Possible values: [external]
The string representation of this type in the catalog
returnColumns
object[]
nullable
The return columns of the function (for TABLE functions)
The name of the return column
dataType
object
required
The general, read-compatible data type representation. UnparsedType preserves types that the current server cannot resolve when reading existing metadata. Endpoints that require resolved new metadata use WritableDataType instead.
oneOf
The string name of a primitive type, such as boolean, byte, byte unsigned, short, short unsigned, integer, integer unsigned, long, long unsigned, float, double, decimal(10,2), date, time(3), timestamp(3), timestamp_tz(3), string, char(10), varchar(10), interval_day, interval_year, uuid, fixed(16) or binary.
string
Possible values: [struct]
fields
object[]
required
The name of the struct field
type
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Default value: true
Whether the struct field is nullable
The comment of the struct field
Possible values: [list]
Default value: true
Whether the list contains null values
elementType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Possible values: [map]
keyType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
valueType
object
required
A nested data type, in any form that DataType describes.
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Default value: true
Whether the value of the map contains null values
Possible values: [union]
types
object[]
required
oneOf
A primitive type, as in PrimitiveType
string
A struct, list, map, union, unparsed or external type, as in DataType
object
Possible values: [unparsed]
The unparsed type
Possible values: [external]
The string representation of this type in the catalog
The comment of the return column
impls
object[]
The implementations of the function definition
oneOf
Possible values: [SQL]
The implementation language. The server matches the value exactly, in uppercase, in both requests and responses.
Possible values: [SPARK, TRINO]
The runtime type of the implementation. Responses return the value in uppercase; requests accept any case.
The SQL expression
resources
object
External resources required by a function implementation
JAR file URIs
File URIs
Archive URIs
properties
object
nullable
Additional properties
Possible values: [JAVA]
The implementation language. The server matches the value exactly, in uppercase, in both requests and responses.
Possible values: [SPARK, TRINO]
The runtime type of the implementation. Responses return the value in uppercase; requests accept any case.
The fully qualified class name
resources
object
External resources required by a function implementation
JAR file URIs
File URIs
Archive URIs
properties
object
nullable
Additional properties
Possible values: [PYTHON]
The implementation language. The server matches the value exactly, in uppercase, in both requests and responses.
Possible values: [SPARK, TRINO]
The runtime type of the implementation. Responses return the value in uppercase; requests accept any case.
The Python handler function
The Python code block
resources
object
External resources required by a function implementation
JAR file URIs
File URIs
Archive URIs
properties
object
nullable
Additional properties
audit
object
required
Audit information for a Gravitino resource.
The user who created the resource
The time the resource was created
The user who last modified the resource
The time the resource was last modified
{
"code": 0,
"function": {
"name": "string",
"functionType": "scalar",
"deterministic": false,
"comment": "string",
"definitions": [
{
"parameters": [
{
"name": "string",
"dataType": "integer",
"comment": "string",
"defaultValue": {}
}
],
"returnType": "integer",
"returnColumns": [
{
"name": "string",
"dataType": "integer",
"comment": "string"
}
],
"impls": [
{},
{},
{}
]
}
],
"audit": {
"creator": "string",
"createTime": "2024-07-29T15:51:28.071Z",
"lastModifier": "string",
"lastModifiedTime": "2024-07-29T15:51:28.071Z"
}
}
}
{
"code": 0,
"function": {
"name": "add_one",
"functionType": "scalar",
"deterministic": true,
"comment": "A simple scalar function that adds one",
"definitions": [
{
"parameters": [
{
"name": "x",
"dataType": "integer"
}
],
"returnType": "integer",
"impls": [
{
"language": "SQL",
"runtime": "SPARK",
"sql": "x + 1"
}
]
}
],
"audit": {
"creator": "user1",
"createTime": "2021-01-01T00:00:00Z",
"lastModifier": "user1",
"lastModifiedTime": "2021-01-01T00:00:00Z"
}
}
}
The request is malformed or fails validation, for example because of invalid JSON, a missing required field or an invalid parameter value. The body is normally an error model, although the server's middleware can return plain text instead.
- application/vnd.gravitino.v1+json
- Schema
- Example (from schema)
- Example
Schema
Possible values: >= 1000 and <= 1100
HTTP response code
Internal type definition of the error
A human-readable message
Deprecated diagnostic stack trace. Enterprise omits it by default because it can expose internal implementation details. Operators can opt in for controlled diagnostics with gravitino.server.webserver.includeErrorStackTrace=true. See OWASP REST Security: Error handling and CWE-209.
{
"code": 1002,
"type": "string",
"message": "string"
}
{
"code": 1003,
"type": "BadRequestException",
"message": "Malformed request"
}
The metalake, catalog or schema does not exist.
- application/vnd.gravitino.v1+json
- Schema
- Example (from schema)
- NoSuchSchemaException
Schema
Possible values: >= 1000 and <= 1100
HTTP response code
Internal type definition of the error
A human-readable message
Deprecated diagnostic stack trace. Enterprise omits it by default because it can expose internal implementation details. Operators can opt in for controlled diagnostics with gravitino.server.webserver.includeErrorStackTrace=true. See OWASP REST Security: Error handling and CWE-209.
{
"code": 1002,
"type": "string",
"message": "string"
}
{
"code": 1003,
"type": "NoSuchSchemaException",
"message": "Failed to operate schema(s) [my_hive_schema1] operation [LOAD] under catalog [my_hive_catalog], reason [NoSuchSchemaException]",
"stack": [
"org.apache.gravitino.exceptions.NoSuchSchemaException: Hive schema (database) does not exist: my_hive_schema1 in Hive Metastore",
"..."
]
}
A function with the same name already exists in the schema.
- application/vnd.gravitino.v1+json
- Schema
- Example (from schema)
- FunctionAlreadyExistsException
Schema
Possible values: >= 1000 and <= 1100
HTTP response code
Internal type definition of the error
A human-readable message
Deprecated diagnostic stack trace. Enterprise omits it by default because it can expose internal implementation details. Operators can opt in for controlled diagnostics with gravitino.server.webserver.includeErrorStackTrace=true. See OWASP REST Security: Error handling and CWE-209.
{
"code": 1002,
"type": "string",
"message": "string"
}
{
"code": 1004,
"type": "FunctionAlreadyExistsException",
"message": "Function already exists",
"stack": [
"org.apache.gravitino.exceptions.FunctionAlreadyExistsException: Function already exists"
]
}
The server hit an internal error that the client usually cannot fix by changing the request.
- application/vnd.gravitino.v1+json
- Schema
- Example (from schema)
- Example
Schema
Possible values: >= 1000 and <= 1100
HTTP response code
Internal type definition of the error
A human-readable message
Deprecated diagnostic stack trace. Enterprise omits it by default because it can expose internal implementation details. Operators can opt in for controlled diagnostics with gravitino.server.webserver.includeErrorStackTrace=true. See OWASP REST Security: Error handling and CWE-209.
{
"code": 1002,
"type": "string",
"message": "string"
}
{
"code": 1002,
"type": "RuntimeException",
"message": "Internal Server Error",
"stack": [
"java.lang.RuntimeException: Internal Server Error"
]
}