DEV Community

Cover image for A concise list of functions available in Apache AGE: Part 1
Bhaskar Sharma
Bhaskar Sharma

Posted on • Updated on

A concise list of functions available in Apache AGE: Part 1

INTRODUCTION

The aim of this blog post is to give a clear cut, concise and short list of all the functions available in Apache AGE. The list is already available in more details in the software documentation, however, this saves you from reading through pages of documentation searching for the relevant function.

In this blog post, we cover Predicate, Scalar, List and Numeric functions.

Predicate functions (True or False type)

Generally used to filter out subgraphs using WHERE clause

  • Exists(Property) - Returns true if the said property exists for the vertex/edge/map.

  • Exists(Path) - Returns true if the given path exists. Can be used to filter out all paths between given vertices

Scalar Functions

Generally used to return certain characteristics of vertices/edges or to cast from one agtype to another.

CATEGORY 1: Returning ids or type or properties of vertex/edge.

  • id(expression) - Returns the id of vertex or edge.

  • start_id(expression) - Returns the id of the vertex where the edge starts.

  • end_id(expression) - Returns the id of the vertex where the edge ends.

  • type(edge) - Returns the string representation of the edge type.

  • properties(expressions) - Returns the properties of a vertex or edge in the form of an agtype map.

  • head(list) - Returns the first element in an agtype list.

  • last(list) - Returns the last element in an agtype list.

  • length(path) - Returns the length of a path (number of edges in it).

  • size(list) - Returns the number of elements in the list.

  • startNode(edge) - Returns the start node of the edge.

  • endNode(edge) - Returns the end node of the edge.

  • timestamp() - Returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

  • coalesce(expression [, expression]*) - Returns the first non-null value in the given list of expressions.

CATEGORY 2: Conversion functions.

  • toBoolean(expression) - converts a string value to a boolean value.

  • toFloat(expression) - converts an integer or string value to a floating point number.

  • toInteger(expression) - converts a floating point or string value to an integer value.

LIST FUNCTIONS

  • keys(expression) - list containing the names of all the properties of what the expression evaluates to.

  • range(start, end [, step]) - Returns an arithmetic progression

  • labels(vertex) - returns a list containing the string representations for all the labels of a node.

  • relationships(path) - returns a list containing all the relationships in a path.

NUMERIC FUNCTIONS

  • rand() - returns a random floating point number in the range from 0 (inclusive) to 1 (exclusive)

  • abs(expression) - returns the absolute value of the given number.

  • ceil(expression) - returns the smallest floating point number that is greater than or equal to the given number and equal to a mathematical integer.

  • floor(expression) - returns the greatest floating point number that is less than or equal to the given number and equal to a mathematical integer.

  • round(expression) - returns the value of the given number rounded to the nearest integer.

  • sign(expression) - returns the signum of the given number.

In the next blog post, we will cover the further functions.

Top comments (0)