User-Defined Functions

User-defined functions extend the SQL computation capabilities of Lakehouse. Two types are supported: SQL Function (executed within the engine) and External Function (calls an external service).

For a detailed introduction, see Function Object Model.


In This Chapter

SQL Function

PageDescription
CREATE SQL FUNCTIONCreate a SQL scalar function or table function
DROP FUNCTIONDrop a function
DESC FUNCTIONView detailed information about a function
SHOW FUNCTIONSList all functions (including built-in functions)

External Function

PageDescription
CREATE EXTERNAL FUNCTIONCreate a function that calls an external service (Python/Java)
DROP FUNCTIONDrop an external function
SHOW EXTERNAL FUNCTIONSList all external functions

Common Operations

-- Create a SQL scalar function CREATE FUNCTION public.area(x DOUBLE, y DOUBLE) RETURNS DOUBLE RETURN x * y; -- Use the function SELECT public.area(3, 4); -- Output: 12.0 -- List all functions SHOW FUNCTIONS; -- Drop a function DROP FUNCTION public.area;


DocumentDescription
Function Object ModelFunction type comparison, permission notes, complete examples
External Function WorkflowComplete process from development to deployment
SQL Function ReferenceComplete list of built-in functions