Operators & functions

Most operations in FeatureQL can be written two ways: as an operator (+, ||, CASE WHEN) or as a function call (ADD(), CONCAT(), CASE_WHEN()). They produce identical results — pick whichever reads better in context.

Operator and function equivalence

Arithmetic, conditionals, and casting all have both forms:

FeatureQL
RETURN
    value_to_test := 2,
    add_operator := 1 + value_to_test,
    add_function := ADD(1, value_to_test),
    case_operator := CASE
        WHEN value_to_test = 1 THEN 'ONE'
        WHEN value_to_test = 2 THEN 'TWO'
        WHEN value_to_test = 3 THEN 'THREE'
        ELSE 'OTHER'
    END,
    case_function := CASE_WHEN(
        ARRAY(value_to_test = 1, value_to_test = 2, value_to_test = 3),
        ARRAY('ONE', 'TWO', 'THREE'),
        'OTHER'
    ),
    cast_operator := '1'::BIGINT,
    cast_function := CAST_PG('1', TYPE 'BIGINT')
;
Result
VALUE_TO_TEST BIGINTADD_OPERATOR BIGINTADD_FUNCTION BIGINTCASE_OPERATOR VARCHARCASE_FUNCTION VARCHARCAST_OPERATOR BIGINTCAST_FUNCTION BIGINT
233TWOTWO11

The function forms are useful when you need to build logic dynamically. CASE_WHEN() takes arrays of conditions and values, which makes it easier to construct programmatically than the traditional CASE WHEN ... END syntax. Note that casting also has a function form: CAST('1', TYPE 'BIGINT') is equivalent to CAST('1' AS BIGINT).

For the full catalog, see Operators and Functions .

Constants

Write nullary constants with parentheses — PI(), E(), EMPTY(), VERSION(). A bare name is a normal identifier, not the constant:

FeatureQL
RETURN
    E(),
    PI(),
    NULL,
    NULL(),
    EMPTY()
Result
?_0 DECIMAL?_1 DECIMAL?_2 VARCHAR?_3 VARCHAR?_4 VARCHAR
2.7182818284590453.141592653589793NULLNULLEMPTY()

E() and PI() are the mathematical constants. VERSION() returns the FeatureQL version. NULL and EMPTY() are the two special values (see Literals for how they differ). A bare E / PI / EMPTY is an identifier, not the constant. INFINITY() and NAN() are not functions: a FeatureQL number must be finite, so those calls raise UE/NON-FINITE-LITERAL.

Discovering functions

Browsing available functions

SHOW FUNCTIONS lists functions by name and category. Use LIKE patterns to narrow the results:

FeatureQL
SHOW FUNCTIONS (COLUMNS (NAME, CATEGORY)) LIKE 'ARR%' ORDER BY NAME LIMIT 10;
Result
NAME VARCHARCATEGORY ARRAY<VARCHAR>
ARRAYS_OVERLAP[Array, Set Operations]
ARRAY_AGG() GROUP BY ...[Group By, Collection]
ARRAY_AGG() OVER ...[Window Function, Collection]
ARRAY_AVG[Array, Aggregation And Statistics]
ARRAY_CONCAT[Array, Array Combination]
ARRAY_CONCAT_FN[Array, Array Combination]
ARRAY_COUNT[Array, Aggregation And Statistics]
ARRAY_DISTINCT[Array, Filtering And Transformation]
ARRAY_ENUMERATE[Array, Filtering And Transformation]
ARRAY_ENUMERATE_FLATTEN[Array, Filtering And Transformation]

Results include CATEGORY (as an array like ['Math', 'Arithmetic']), DISPLAY_ORDER for sorting, and optional columns like ALIASES, OPERATOR, PARAMETERS, and NOTES. Use INCLUDE (SIGNATURES, EXAMPLES) for nested ARRAY(ROW(...)) overloads and registry examples.

Inspecting function signatures

SHOW FUNCTIONS (INCLUDE (SIGNATURES)) returns an ARRAY(ROW(...)) of overloads. Flatten with hybrid SQL:

FeatureQL
SELECT
    f.NAME,
    (s).PARAMETER_NAMES AS PARAMETER_NAMES,
    (s).PARAMETER_TYPES AS PARAMETER_TYPES,
    (s).RETURN_TYPE AS RETURN_TYPE
FROM FEATUREQL(SHOW FUNCTIONS (INCLUDE (SIGNATURES)) WHERE NAME = 'ADD' LIMIT 1) f,
UNNEST(f.SIGNATURES) AS t(s);
Result
NAME VARCHARPARAMETER_NAMES ARRAY<VARCHAR>PARAMETER_TYPES ARRAY<VARCHAR>RETURN_TYPE VARCHAR
ADD[number1, number2][T, T]T
ADD[timestamp, interval][TIMESTAMP, INTERVAL]TIMESTAMP
ADD[date, interval][DATE, INTERVAL]TIMESTAMP
ADD[interval, timestamp][INTERVAL, TIMESTAMP]TIMESTAMP
ADD[interval, date][INTERVAL, DATE]TIMESTAMP

Each row is one overload. PARAMETER_NAMES and PARAMETER_TYPES are arrays, so ADD shows its numeric overloads and its date/interval overload side by side.

The same SHOW FUNCTIONS examples, plus SHOW DOCS, SHOW TESTS, and SHOW CREATE, are on Statement tools .

Next

Friendly syntax — dependency order, chaining, := vs AS.