Summary of Built-in Functions
Cloudberry Database supports built-in functions and operators including analytic functions and window functions that can be used in window expressions.
📄️ JSON Functions and Operators
This document describes:
📄️ Window Functions
The following are Cloudberry Database built-in window functions. All window functions are immutable.
📄️ Advanced Aggregate Functions
The following built-in advanced analytic functions are Cloudberry extensions of the PostgreSQL database. Analytic functions are immutable.
📄️ Text Search Functions and Operators
The following tables summarize the functions and operators that are provided for full text searching.
📄️ Range Functions and Operators
The following table shows the operators available for range types.
Cloudberry Database function types
Cloudberry Database evaluates functions and operators used in SQL expressions. Some functions and operators are only allowed to run on the coordinator since they could lead to inconsistencies in Cloudberry Database segment instances. This table describes the Cloudberry Database Function Types.
Function Type | Cloudberry Support | Description | Comments |
---|---|---|---|
IMMUTABLE | Yes | Relies only on information directly in its argument list. Given the same argument values, always returns the same result. | |
STABLE | Yes, in most cases | Within a single table scan, returns the same result for same argument values, but results change across SQL statements. | Results depend on database lookups or parameter values. current_timestamp family of functions is STABLE ; values do not change within an execution. |
VOLATILE | Restricted | Function values can change within a single table scan. For example: random() , timeofday() . | Any function with side effects is volatile, even if its result is predictable. For example: setval() . |
In Cloudberry Database, data is divided up across segments — each segment is a distinct PostgreSQL database. To prevent inconsistent or unexpected results, do not run functions classified as VOLATILE
at the segment level if they contain SQL commands or modify the database in any way. For example, functions such as setval()
are not allowed to run on distributed data in Cloudberry Database because they can cause inconsistent data between segment instances.
To ensure data consistency, you can safely use VOLATILE
and STABLE
functions in statements that are evaluated on and run from the coordinator. For example, the following statements run on the coordinator (statements without a FROM
clause):
SELECT setval('myseq', 201);
SELECT foo();
If a statement has a FROM
clause containing a distributed table and the function in the FROM
clause returns a set of rows, the statement can run on the segments:
SELECT * from foo();
Cloudberry Database does not support functions that return a table reference (rangeFuncs
) or functions that use the refCursor
datatype.
Built-in functions and operators
The following table lists the categories of built-in functions and operators supported by PostgreSQL. All functions and operators are supported in Cloudberry Database as in PostgreSQL with the exception of STABLE
and VOLATILE
functions, which are subject to the restrictions noted in Cloudberry Database Function Types. See the Functions and Operators section of the PostgreSQL documentation for more information about these built-in functions and operators.
Operator/Function Category | VOLATILE Functions | STABLE Functions | Restrictions |
---|---|---|---|
Logical Operators | |||
Comparison Operators | |||
Mathematical Functions and Operators | random setseed | ||
String Functions and Operators | All built-in conversion functions | convert pg_client_encoding | |
Binary String Functions and Operators | |||
Bit String Functions and Operators | |||
Pattern Matching | |||
Data Type Formatting Functions | to_char to_timestamp | ||
Date/Time Functions and Operators | timeofday | age current_date current_time current_timestamp localtime localtimestamp now | |
Enum Support Functions | |||
Geometric Functions and Operators | |||
Network Address Functions and Operators | |||
Sequence Manipulation Functions | nextval() setval() | ||
Conditional Expressions | |||
Array Functions and Operators |