All functions#

This page lists every function documented in this reference, 126 entries in all, in one alphabetical table. A function can be found by name without knowing which category it belongs to. The Function column links to the full entry, which carries the considerations and a worked example. The Signature column shows every overload the catalog holds.

Where two entries share a name, they are two functions with two OIDs and two meanings. length over a string is not length over a path, and the signature column tells them apart.

Function

Signature

Description

Availability

abs

abs ( x jsonb ) -> jsonb
abs ( x numeric ) -> numeric

Returns the absolute value of a number.

2.17 and earlier

acos

acos ( x jsonb ) -> jsonb
acos ( x double precision ) -> double precision

Returns the arc cosine of x, in radians.

2.17 and earlier

ag_get_graphconstraintdef

ag_get_graphconstraintdef ( constraint oid ) -> text

Reconstructs the CREATE CONSTRAINT command for a graph constraint, given its OID.

2.17 and earlier

ag_get_propindexdef

ag_get_propindexdef ( index oid ) -> text

Reconstructs the CREATE PROPERTY INDEX command for a property index, given its OID.

2.17 and earlier

ag_property_text

ag_property_text ( properties jsonb, key text, expected_kind “char” ) -> text

Returns a property’s value as text, but only when the stored value is of the JSON kind asked for.

Added in 2.18

agversion

agversion ( ) -> text

The AgensGraph version of the running server.

2.17 and earlier

all

all ( variable IN list WHERE predicate ) -> boolean

Returns true when the predicate holds for every element of the list.

2.17 and earlier

allshortestpaths

allshortestpaths ( pattern ) -> graphpath

Every shortest path between two vertices.

2.17 and earlier

any

any ( variable IN list WHERE predicate ) -> boolean

Returns true when the predicate holds for at least one element of the list.

2.17 and earlier

array_size

array_size ( list jsonb ) -> integer
array_size ( list json ) -> integer
array_size ( list anyarray ) -> integer

Returns the number of elements in an array.

2.17 and earlier

asin

asin ( x jsonb ) -> jsonb
asin ( x double precision ) -> double precision

Returns the arc sine of x, in radians.

2.17 and earlier

atan

atan ( x jsonb ) -> jsonb
atan ( x double precision ) -> double precision

Returns the arc tangent of x, in radians.

2.17 and earlier

atan2

atan2 ( y jsonb, x jsonb ) -> jsonb
atan2 ( y double precision, x double precision ) -> double precision

Arc tangent of y / x in radians, using both signs to fix the quadrant.

2.17 and earlier

avg

avg ( expression numeric ) -> numeric

Returns the arithmetic mean of the non-null values in the group.

2.17 and earlier

cardinality

cardinality ( value jsonb ) -> jsonb
cardinality ( p graphpath ) -> jsonb

Returns the number of elements in a list, entries in a map, or vertices and edges in a path.

Added in 2.18

ceil

ceil ( x jsonb ) -> jsonb
ceil ( x numeric ) -> numeric

Returns the smallest integer that is not less than x.

2.17 and earlier

coalesce

coalesce ( value [, value ] … ) -> jsonb

Returns the first argument that is not null.

2.17 and earlier

collect

collect ( expression anyelement ) -> jsonb
collect ( v vertex ) -> vertex[]
collect ( e edge ) -> edge[]
collect ( p graphpath ) -> graphpath[]

Gathers the group’s values into a list; a graph element gives a native array.

2.17 and earlier

cos

cos ( x jsonb ) -> jsonb
cos ( x double precision ) -> double precision

Returns the cosine of an angle given in radians.

2.17 and earlier

cosd

cosd ( x double precision ) -> double precision

Returns the cosine of an angle given in degrees.

2.17 and earlier

cot

cot ( x jsonb ) -> jsonb
cot ( x double precision ) -> double precision

Returns the cotangent of an angle given in radians — the reciprocal of the tangent.

2.17 and earlier

count

count ( * ) -> bigint
count ( expression ) -> bigint

Counts rows in the group.

2.17 and earlier

cypher_to_jsonb

cypher_to_jsonb ( value anyelement ) -> jsonb

Boxes a value to jsonb using Cypher’s rules; refuses a graph type.

2.17 and earlier

datetime

datetime ( ) -> timestamp with time zone
datetime ( timezone “any” ) -> timestamp without time zone
datetime ( year integer, month integer, mday integer, hour integer, min integer, sec integer, millisec integer, nanosec integer, timezone “any” ) -> timestamp without time zone

The current transaction timestamp, the time in a named zone, or a timestamp built from parts.

2.17 and earlier

degrees

degrees ( x jsonb ) -> jsonb
degrees ( x double precision ) -> double precision

Converts radians to degrees.

2.17 and earlier

dijkstra

dijkstra ( pattern, weight ) -> graphpath
dijkstra ( pattern, weight, condition ) -> graphpath
dijkstra ( pattern, weight, LIMIT count ) -> graphpath
dijkstra ( pattern, weight, condition, LIMIT count ) -> graphpath

Finds the cheapest path between two vertices, where each edge costs what weight evaluates to.

2.17 and earlier

e

e ( ) -> numeric

Returns Euler’s number as a numeric.

2.17 and earlier

edge_to_jsonb

edge_to_jsonb ( e edge ) -> jsonb

Returns an edge’s property bag.

2.17 and earlier

edges

edges ( p graphpath ) -> edge[]

Returns the edges of a path, in order.

2.17 and earlier

end_id

end_id ( e edge ) -> graphid

Returns the graphid of the vertex an edge points at, without reading that vertex.

2.17 and earlier

end_vertex

end_vertex ( e edge ) -> vertex

Returns the vertex an edge points at.

2.17 and earlier

endNode

endNode ( e edge ) -> vertex

Returns the vertex an edge points at.

2.17 and earlier

exists

exists ( pattern ) -> boolean
exists ( property_reference ) -> boolean

True when a pattern matches at least once, or when a property is present and not null.

2.17 and earlier

exp

exp ( x jsonb ) -> jsonb
exp ( x numeric ) -> numeric

Returns e raised to the power x.

2.17 and earlier

floor

floor ( x jsonb ) -> jsonb
floor ( x numeric ) -> numeric

Returns the largest integer that is not greater than x.

2.17 and earlier

get_last_graph_write_stats

get_last_graph_write_stats ( ) -> record

What the most recent graph write in this session changed, as five counters.

2.17 and earlier

get_time

get_time ( ) -> time without time zone
get_time ( timezone “any” ) -> time without time zone

Returns the current time of day, either locally or in a named zone.

2.17 and earlier

graph_labid

graph_labid ( qualified_label cstring ) -> integer

Returns the label id of a label named as graph.label.

2.17 and earlier

graphid

graphid ( labid integer, locid bigint ) -> graphid
graphid ( id numeric ) -> graphid

Builds a graphid from a label id and a local id, or from its printed form.

2.17 and earlier

graphid_in_jsonb_array

graphid_in_jsonb_array ( id graphid, elements jsonb ) -> boolean

Returns true when a graphid is one of the graph elements in a jsonb array.

2.17 and earlier

graphid_labid

graphid_labid ( id graphid ) -> integer

Returns the label part of a graphid — the number before the dot.

2.17 and earlier

graphid_locid

graphid_locid ( id graphid ) -> bigint

Returns the local part of a graphid — the number after the dot, taken from the label’s sequence.

2.17 and earlier

head

head ( list jsonb ) -> jsonb
head ( list anyarray ) -> anyelement

Returns the first element of a list.

2.17 and earlier

id

id ( v vertex ) -> graphid
id ( e edge ) -> graphid

Returns a graph element’s identity.

2.17 and earlier

isEmpty

isEmpty ( value jsonb ) -> boolean

Returns true when a list has no elements or a map has no keys.

2.17 and earlier

jsonb_add

jsonb_add ( a jsonb, b jsonb ) -> jsonb

Implements the backtick + operator: addition, or concatenation of two strings or two lists.

2.17 and earlier

jsonb_array_length

jsonb_array_length ( list jsonb ) -> integer

Returns the number of elements in a jsonb array, as an integer.

2.17 and earlier

jsonb_div

jsonb_div ( a jsonb, b jsonb ) -> jsonb

Implements the backtick / operator. Integer division when both operands are integers.

2.17 and earlier

jsonb_mod

jsonb_mod ( a jsonb, b jsonb ) -> jsonb

Implements the backtick % operator.

2.17 and earlier

jsonb_mul

jsonb_mul ( a jsonb, b jsonb ) -> jsonb

Implements the backtick * operator.

2.17 and earlier

jsonb_pow

jsonb_pow ( a jsonb, b jsonb ) -> jsonb

Implements the backtick ^ operator.

2.17 and earlier

jsonb_sub

jsonb_sub ( a jsonb, b jsonb ) -> jsonb

Implements the backtick binary - operator.

2.17 and earlier

jsonb_uminus

jsonb_uminus ( a jsonb ) -> jsonb

Implements the backtick prefix - operator.

2.17 and earlier

jsonb_uplus

jsonb_uplus ( a jsonb ) -> jsonb

Implements the backtick prefix + operator.

2.17 and earlier

keys

keys ( map jsonb ) -> jsonb

Returns a list of the key names of a map, or of a graph element’s properties.

2.17 and earlier

label

label ( v vertex ) -> jsonb
label ( e edge ) -> jsonb

Returns the name of the label a graph element was created with, as a jsonb string.

2.17 and earlier

labels

labels ( v vertex ) -> jsonb

Returns a list holding the vertex’s own label and every label it inherits from, nearest first.

2.17 and earlier

last

last ( list jsonb ) -> jsonb
last ( list anyarray ) -> anyelement

Returns the final element of a list.

2.17 and earlier

left

left ( string jsonb, n jsonb ) -> jsonb
left ( string text, n integer ) -> text

Returns the first n characters of a string.

2.17 and earlier

length

length ( p graphpath ) -> jsonb
length ( vs vertex[] ) -> jsonb
length ( es edge[] ) -> jsonb
length ( ps graphpath[] ) -> jsonb

Edges in a path, or elements of an array of graph elements.

2.17 and earlier

length

length ( value jsonb ) -> jsonb

Characters in a string, elements in a list, or keys in a map.

2.17 and earlier

ln

ln ( x double precision ) -> double precision
ln ( x numeric ) -> numeric

Natural logarithm of x. The function log resolves to in Cypher.

2.17 and earlier

localdatetime

localdatetime ( ) -> timestamp with time zone
localdatetime ( timezone “any” ) -> timestamp without time zone

Returns the current transaction timestamp, or the current wall-clock reading in a named zone.

2.17 and earlier

log

log ( x jsonb ) -> jsonb

Natural logarithm of x — not base 10, and with no base argument.

2.17 and earlier

log10

log10 ( x double precision ) -> double precision
log10 ( x numeric ) -> numeric

Returns the base-10 logarithm of x.

2.17 and earlier

lower

lower ( string text ) -> text

Returns the string in lower case.

2.17 and earlier

lTrim

lTrim ( string jsonb ) -> jsonb

Removes whitespace from the start of a string.

2.17 and earlier

max

max ( expression jsonb ) -> jsonb
max ( expression numeric ) -> numeric

Returns the largest value in the group.

2.17 and earlier

min

min ( expression jsonb ) -> jsonb
min ( expression numeric ) -> numeric

Returns the smallest value in the group.

2.17 and earlier

nodes

nodes ( p graphpath ) -> vertex[]

The vertices of a path, in order.

2.17 and earlier

none

none ( variable IN list WHERE predicate ) -> boolean

Returns true when the predicate holds for no element of the list — the negation of any.

2.17 and earlier

percentileCont

percentileCont ( list jsonb, percentile numeric ) -> double precision

Percentile of a list of numbers, interpolated between neighbouring values.

2.17 and earlier

percentileDisc

percentileDisc ( list jsonb, percentile numeric ) -> double precision

Percentile of a list of numbers, rounded down to a value in the list.

2.17 and earlier

pi

pi ( ) -> double precision

Returns π.

2.17 and earlier

properties

properties ( v vertex ) -> jsonb
properties ( e edge ) -> jsonb

Returns a graph element’s whole property bag as a map.

2.17 and earlier

radians

radians ( x jsonb ) -> jsonb
radians ( x double precision ) -> double precision

Converts degrees to radians.

2.17 and earlier

rand

rand ( ) -> jsonb

Returns a number in the half-open range 0 to 1.

2.17 and earlier

range

range ( start integer, stop integer ) -> jsonb
range ( start integer, stop integer, step integer ) -> jsonb

Returns a list of integers from start to stop, inclusive at both ends.

2.17 and earlier

regather_graphmeta

regather_graphmeta ( ) -> boolean

Empties ag_graphmeta and rebuilds it by scanning every edge label in the current graph.

2.17 and earlier

relationships

relationships ( p graphpath ) -> edge[]

Returns the edges of a path, in order.

2.17 and earlier

replace

replace ( string jsonb, old jsonb, new jsonb ) -> jsonb

Replaces every occurrence of one substring with another.

2.17 and earlier

reverse

reverse ( string text ) -> text
reverse ( list jsonb ) -> jsonb
reverse ( list anyarray ) -> anyarray

Reverses a list, or a string given as a literal or cast to text.

2.17 and earlier

right

right ( string jsonb, n jsonb ) -> jsonb
right ( string text, n integer ) -> text

Returns the last n characters of a string.

2.17 and earlier

round

round ( x jsonb ) -> jsonb
round ( x numeric [, scale integer ] ) -> numeric

Rounds x to the nearest integer, halves away from zero.

2.17 and earlier

rTrim

rTrim ( string jsonb ) -> jsonb

Removes whitespace from the end of a string.

2.17 and earlier

shortestpath

shortestpath ( pattern ) -> graphpath

Finds one shortest path between two vertices, by number of edges.

2.17 and earlier

sign

sign ( x jsonb ) -> jsonb
sign ( x numeric ) -> numeric

Returns −1, 0 or 1 according to the sign of x.

2.17 and earlier

sin

sin ( x double precision ) -> double precision

Returns the sine of an angle given in radians.

2.17 and earlier

sind

sind ( x double precision ) -> double precision

Returns the sine of an angle given in degrees.

2.17 and earlier

single

single ( variable IN list WHERE predicate ) -> boolean

Returns true when the predicate holds for exactly one element of the list.

2.17 and earlier

size

size ( value ) -> jsonb
size ( pattern ) -> bigint

The length of a value, or the number of times a pattern matches.

2.17 and earlier

split

split ( string text, delimiter text ) -> anyarray

Cuts a string into a list at every occurrence of a delimiter.

2.17 and earlier

sqrt

sqrt ( x jsonb ) -> jsonb
sqrt ( x numeric ) -> numeric

Returns the square root of x.

2.17 and earlier

start_id

start_id ( e edge ) -> graphid

Returns the graphid of the vertex an edge leaves, without reading that vertex.

2.17 and earlier

start_vertex

start_vertex ( e edge ) -> vertex

Returns the vertex an edge leaves.

2.17 and earlier

startNode

startNode ( e edge ) -> vertex

Returns the vertex an edge leaves.

2.17 and earlier

stdev

stdev ( expression numeric ) -> numeric

Sample standard deviation of the values in the group.

2.17 and earlier

stdevp

stdevp ( expression numeric ) -> numeric

Population standard deviation of the values in the group.

2.17 and earlier

str_size

str_size ( string text ) -> integer

Returns the number of characters in a string, as an integer.

2.17 and earlier

string_contains

string_contains ( a jsonb, b jsonb ) -> boolean

Implements CONTAINS. True when the right string occurs anywhere in the left.

2.17 and earlier

string_ends_with

string_ends_with ( a jsonb, b jsonb ) -> boolean

Implements ENDS WITH. True when the left string ends with the right.

2.17 and earlier

string_regex

string_regex ( a jsonb, b jsonb ) -> boolean

Implements =~. True when the left string matches the right as a regular expression.

2.17 and earlier

string_starts_with

string_starts_with ( a jsonb, b jsonb ) -> boolean

Implements STARTS WITH. True when the left string begins with the right.

2.17 and earlier

substring

substring ( string jsonb, start jsonb ) -> jsonb
substring ( string jsonb, start jsonb, count jsonb ) -> jsonb

Returns part of a string, starting at start and running to the end or for count characters.

2.17 and earlier

sum

sum ( expression numeric ) -> numeric

Returns the total of the non-null values in the group.

2.17 and earlier

tail

tail ( list jsonb ) -> jsonb
tail ( list anyarray ) -> anyarray

Returns every element of a list except the first.

2.17 and earlier

tan

tan ( x jsonb ) -> jsonb
tan ( x double precision ) -> double precision

Returns the tangent of an angle given in radians.

2.17 and earlier

tand

tand ( x double precision ) -> double precision

Returns the tangent of an angle given in degrees.

2.17 and earlier

to_jsonb

to_jsonb ( value anyelement ) -> jsonb

Converts any SQL value to jsonb, a composite becoming an object.

2.17 and earlier

toBoolean

toBoolean ( value text ) -> boolean
toBoolean ( value “any” ) -> boolean

Returns the boolean a value names, or null when it names none.

2.17 and earlier

toBooleanOrNull

toBooleanOrNull ( value text ) -> boolean
toBooleanOrNull ( value “any” ) -> boolean

Returns the boolean a value names, or null.

2.17 and earlier

toFloat

toFloat ( value “any” ) -> double precision

Returns the floating-point number a value names, or null.

Added in 2.18

toFloatList

toFloatList ( list jsonb ) -> jsonb
toFloatList ( list anyarray ) -> double precision[]

Converts every element of a list to a floating-point number.

2.17 and earlier

toInteger

toInteger ( value “any” ) -> bigint

Returns the integer a value names, or null.

Added in 2.18

toIntegerList

toIntegerList ( list jsonb ) -> jsonb
toIntegerList ( list anyarray ) -> bigint[]

Converts every element of a list to an integer.

2.17 and earlier

toLower

toLower ( string jsonb ) -> jsonb

Returns the string in lower case.

2.17 and earlier

toString

toString ( value jsonb ) -> jsonb

Returns the string form of a value.

2.17 and earlier

toStringList

toStringList ( list jsonb ) -> jsonb
toStringList ( list anyarray ) -> text[]

Converts every element of a list to a string.

2.17 and earlier

toStringOrNull

toStringOrNull ( value “any” ) -> text

Returns the string form of a value, or null when the value has no string form.

2.17 and earlier

toUpper

toUpper ( string jsonb ) -> jsonb

Returns the string in upper case.

2.17 and earlier

trim

trim ( string jsonb ) -> jsonb

Removes whitespace from both ends of a string.

2.17 and earlier

type

type ( e edge ) -> jsonb

Returns the name of an edge’s label, as a jsonb string — the same value as label(e), under the name Cypher uses for relationship types.

2.17 and earlier

unnest

unnest ( from_json jsonb ) -> setof jsonb

Expands a list into one row per element.

Added in 2.18

upper

upper ( string text ) -> text

Returns the string in upper case.

2.17 and earlier

vertex_to_jsonb

vertex_to_jsonb ( v vertex ) -> jsonb

Returns a vertex’s property bag.

2.17 and earlier

vertices

vertices ( p graphpath ) -> vertex[]

Returns the vertices of a path, in order.

2.17 and earlier

collect is older than 2.18, but its native-array results arrived with this release: vertex[], edge[] and graphpath[] in place of jsonb. So did the three-valued implementations behind all, any, none and single. The 2.18 release notes carry the full list of changes.

Functions documented elsewhere#

The meta schema adds functions for inspecting graphs, labels and their sizes from SQL: meta.labels(), meta.count(), meta.label_size() and the rest. It is an extension rather than part of the core catalog, so a database has it only once it is installed. Those functions are documented on their own page, Graph metadata, and are not repeated here.

Every function PostgreSQL itself provides is also reachable from a Cypher query, subject to the type rules described on each page here. The PostgreSQL documentation is the reference for those.

What this reference leaves out#

The functions AgensGraph adds occupy the object-identifier range 7000 to 8100. Not all of them are meant to be called. The range also holds type input and output functions, comparison and hash support for the B-tree and GIN operator classes, and aggregate transition and final functions. It holds a planner support function, two pg_upgrade helpers, and four placeholder entries the path-finding executor resolves. This reference documents the ones a query can use, and omits those.

List what your own build exposes#

The catalog is the authority on what a given server has. This lists every AgensGraph function in that range, aggregates included:

SELECT p.proname AS function,
       pg_catalog.pg_get_function_identity_arguments(p.oid) AS arguments,
       pg_catalog.format_type(p.prorettype, NULL) AS returns,
       CASE p.prokind WHEN 'a' THEN 'aggregate' ELSE 'function' END AS kind,
       obj_description(p.oid, 'pg_proc') AS description
FROM pg_catalog.pg_proc p
WHERE p.oid BETWEEN 7000 AND 8100
ORDER BY p.proname, p.oid;

On this 2.18 server that returns 195 rows. That is more than this reference documents, because of the support entries listed above. To count them instead:

SELECT count(*) FROM pg_catalog.pg_proc WHERE oid BETWEEN 7000 AND 8100;
 count
-------
   195

A function whose name AgensGraph does not add will not appear, because it belongs to PostgreSQL. avg, min, left and log10 are among those. Drop the WHERE clause and filter by name to find one of them.

See also#