CREATE FUNCTION Statements

CREATE FUNCTION statements can create two different kinds of functions:

  • User defined SQL functions let you define and store commonly-used SQL expressions as a function. User defined SQL functions are useful for executing complex queries and combining Vertica built-in functions. You simply call the function name you assigned in your query.
  • User defined scalar functions (UDSFs) take in a single row of data and return a single value. These functions can be used anywhere a native Vertica function or statement can be used, except CREATE TABLE with its PARTITION BY or any segmentation clause.

While you use CREATE FUNCTION to create both SQL and scalar functions, you use a different syntax for each function type. For more information, see:

About Creating User Defined Transform Functions (UDTFs)

You can use a similar SQL statement to create user-defined transform functions. User defined transform functions (UDTFs) operate on table segments and return zero or more rows of data. The data they return can be an entirely new table, unrelated to the schema of the input table, including having its own ordering and segmentation expressions. They can only be used in a query's SELECT list. For details about creating a UDTF, see CREATE TRANSFORM FUNCTION.