CREATE FUNCTION#

Synopsis#

CREATE [OR REPLACE] FUNCTION
  udf_definition

Description#

Create or replace a catalog UDF. The udf_definition is composed of FUNCTION and nested statements. For Starburst Galaxy, the function name can be the simple name of the function, or that name prefixed by galaxy.functions. All SQL function in Galaxy are stored in the same location, which is a global catalog named galaxy that is automatically attached to each cluster in your Galaxy account.

The optional OR REPLACE clause causes the UDF to be replaced if it already exists rather than raising an error.

Examples#

The following example creates the meaning_of_life UDF in the functions schema of the galaxy catalog:

CREATE FUNCTION meaning_of_life()
  RETURNS bigint
  BEGIN
    RETURN 42;
  END;

You can also specify the full path to the function, but in Galaxy, this is not necessary:

CREATE FUNCTION galaxy.functions.meaning_of_life()

You can use the following more compact syntax:

CREATE FUNCTION meaning_of_life() RETURNS bigint RETURN 42;

Further examples of varying complexity that cover usage of the FUNCTION statement in combination with other statements are available in the SQL UDF examples documentation.

See also#