4.7. Function Namespace Managers

Warning

This is an experimental feature being actively developed. The wayFunction Namespace Managers are configured might be changed.

Function namespace managers support storing and retrieving SQLfunctions, allowing the Presto engine to perform actions such ascreating, altering, deleting functions.

A function namespace is in the format of catalog.schema (e.g.example.test). It can be thought of as a schema for storingfunctions. However, it is not a full fledged schema as it does notsupport storing tables and views, but only functions.

Each Presto function, whether built-in or user-defined, resides ina function namespace. All built-in functions reside in thepresto.default function namespace. The qualified function name ofa function is the function namespace in which it reside followed byits function name (e.g. example.test.func). Built-in functions canbe referenced in queries with their function namespaces omitted, whileuser-defined functions needs to be referenced by its qualified functionname. A function is uniquely identified by its qualified function nameand parameter type list.

Each function namespace manager binds to a catalog name and manages allfunctions within that catalog. Using the catalog name of an existingconnector is discouraged, as the behavior is not defined nor tested,and will be disallowed in the future.

Currently, those catalog names do not correspond to real catalogs.They cannot be specified as the catalog in a session, nor do theysupport CREATE SCHEMA, ALTER SCHEMA,DROP SCHEMA, or SHOW SCHEMAS. Instead,namespaces can be added using the methods described below.

Configuration

Presto currently stores all function namespace manager relatedinformation in MySQL.

To instantiate a MySQL-based function namespace manager that managescatalog example, administrator needs to first have a running MySQLserver. Suppose the MySQL server can be reached at localhost:1080,add a file etc/function-namespace/example.properties with thefollowing contents:

  1. function-namespace-manager.name=mysql
  2. database-url=localhost:1080
  3. function-namespaces-table-name=example_function_namespaces
  4. functions-table-name=example_sql_functions

When Presto first starts with the above MySQL function namespacemanager configuration, two MySQL tables will be created if they donot exist.

  • example_function_namespaces stores function namespaces ofthe catalog example.
  • example_sql_functions stores SQL-invoked functions of thecatalog example.
Multiple function namespace managers can be instantiated by placingmultiple properties files under etc/function-namespace. Theymay be configured to use the same tables. If so, each manager willonly create and interact with entries of the catalog to which it binds.

To create a new function namespace, insert into theexample_function_namespaces table:

  1. INSERT INTO example_function_namespaces (catalog_name, schema_name)
  2. VALUES('example', 'test');

Configuration Reference

function-namespace-manager.name is the type of the function namespace manager to instantiate. Currently, only mysql is supported.

The following table lists all configuration properties supported by the MySQL function namespace manager.

NameDescription
database-urlThe URL of the MySQL database used by the MySQL function namespace manager.
function-namespaces-table-nameThe name of the table that stores all the function namespaces managed by this manager.
functions-table-nameThe name of the table that stores all the functions managed by this manager.