Supported SQL and functions
The connector provides read and write access to data and metadata in Gravitino, and exposes Gravitino-registered functions as Trino language functions.
SQL
Reads, writes, schema and table management, and transactions all work, following
Trino's SQL support. That covers
SELECT, INSERT, UPDATE, DELETE, MERGE, the SHOW family, CREATE SCHEMA, DROP SCHEMA,
CREATE TABLE, CREATE TABLE AS SELECT, DROP TABLE, ALTER TABLE, COMMENT, and
START TRANSACTION, COMMIT, and ROLLBACK.
CREATE OR REPLACE TABLE AS SELECT is not supported. Drop the table and recreate it.
A statement listed here can still fail if the catalog behind it does not implement the operation. Per-catalog limitations are on Supported catalogs.
User-Defined Functions
Functions registered in Gravitino with a TRINO runtime and a SQL implementation are exposed
automatically. Nothing is declared in Trino.
For each schema the connector lists the functions on the Gravitino server, keeps those with a
TRINO runtime and a SQL implementation, and maps each to a Trino LanguageFunction with a
signature derived from the function name and parameter types. The catalog has to implement
FunctionCatalog.
Registration happens through Gravitino.
FunctionCatalog functionCatalog = catalog.asFunctionCatalog();
functionCatalog.registerFunction(
NameIdentifier.of("{schema}", "add_one"),
"Adds one to input",
FunctionType.SCALAR,
true,
FunctionDefinitions.of(
FunctionDefinitions.of(
FunctionParams.of(FunctionParams.of("x", Types.IntegerType.get())),
Types.IntegerType.get(),
FunctionImpls.of(
FunctionImpls.ofSql(FunctionImpl.RuntimeType.TRINO, "RETURN x + 1")))));
The function is then callable as {catalog}.{schema}.add_one(5) and appears in
SHOW FUNCTIONS FROM {catalog}.{schema}.
Functions are read-only from Trino: CREATE FUNCTION and DROP FUNCTION are not supported. Only
SQL implementations are mapped, so Java and Python implementations stay invisible, as do functions
registered with a runtime other than TRINO. A function using a type with no Trino conversion is
skipped with a warning in the log rather than failing at query time.