Skip to content
Blog

Utility functions

This section is to provide an overview of specific functions that are difficult to categorize, but are broadly useful.

FunctionDescriptionExampleResult
coalesce(arg1, arg2)returns the first non-NULL value from the list of elementscoalesce(NULL, 'a', NULL)'a'
ifnull(arg1, arg2)a two-argument version of coalesceifnull(NULL, 'a')'a'
nullif(arg1, arg2)if arg1 = arg2 return null, otherwise return arg1nullif('hello', 'world')'hello'
constant_or_null(arg1, arg2)if arg2 is null return null, otherwise return arg1constant_or_null(1, NULL)NULL
count_if(arg)if arg is true or non-zero number return 1, other wise return 0count_if(true)1
typeof(arg)return name of the data type of argtypeof(true)BOOL
error(arg)throw arg as a Runtime exceptionerror('something is wrong.')