Cypher Functions

This section describes AnzoGraph DB compatibility with the Cypher Language specification for Cypher functions.

Predicate Functions (Supported)

These functions return either true or false for the given arguments. Cypher predicate functions include the following:

  • exists(): Returns true if the specified property exists in the node, relationship, or map.

Scalar Functions (Partially Supported)

Cypher functions that return a single value include the following:

  • coalesce(): Returns the first non-null value in a list of expressions.
  • endNode(): Returns the end node of a relationship.
  • head(): Returns the first element in a list.
  • id(): Returns the id of a relationship or node.

    In AnzoGraph DB, nodes have a unique integer identifier, however, relationships do not; so id() on relationships is not available. Relationships can, however, be uniquely identified by their start and end node IDs and relationship type.

  • last(): Returns the last element in a list.
  • length(): Returns the length of a path.

    Paths are not supported in the current AnzoGraph DB release, so functions on path arguments are also not supported.

  • properties(): Returns a map containing all the properties of a node or relationship.
  • size(): Returns the number of items in a list. When applied to a pattern expression, the function returns the number of sub-graphs matching the pattern expression. When applied to a string, the function returns the size of a string.
  • startNode(): Returns the start node of a relationship.
  • timestamp(): Returns the difference, measured in milliseconds, between the current time and midnight January 1 1970 UTC.

    Date/time functions are not supported in the current AnzoGraph DB release.

  • toBoolean(): Converts a string value to a boolean value.
  • toFloat(): Converts an integer or string value to a floating point number.
  • toInteger(): Converts a floating point or string value to an integer value.
  • type(): Returns the string representation of the relationship type.

Aggregating Functions (Supported)

Aggregating functions accept multiple values as arguments and calculate and return an aggregated result value.

  • avg(): Returns the average of a set of numeric values.
  • collect(): Returns a list containing the values returned by an expression.
  • count(): Returns the number of values or records.
  • max(): Returns the maximum value in a set of values.

    The max() function is not supported on List types in the current release.

  • min(): Returns the minimum value in a set of values.

    In the current AnzoGraph DB release, there is a result mismatch for min(val) due to different orderability behavior. The min() function on List types is also not supported in the current release.

  • percentileCont(): Returns the percentile of a value over a group using linear interpolation.

    The percentileCont() function is partially supported in the current AnzoGraph DB release, with the percentileCont() function supported with the GROUP BY clause.

  • percentileDisc(): Returns the nearest value to a specified percentile over a group using a rounding method.

    The percentileDisc() function is partially supported in the current AnzoGraph DB release, with the percentileDisc() function supported with the GROUP BY clause.

  • stDev(): Returns the standard deviation for a given value over a group for a sample of a population.
  • stDevP(): Returns the standard deviation for a given value over a group for an entire population.
  • sum(): Returns the sum of a set of numeric values.

List Functions (Supported)

Cypher List functions include the following:

  • keys(): Returns a list containing the string representations for all the property names of a node relationship or map.
  • labels(): Returns a list containing the string representations for all the labels of a node.
  • nodes(): Returns a list containing all the nodes in a path.

    Paths are not supported in the current AnzoGraph DB release, so functions on path arguments are also not supported.

  • range(): Returns a list comprising all integer values within a specified range.
  • relationships(): Returns a list containing all the relationships in a path.

    Paths are not supported in the current AnzoGraph DB release, so functions on path arguments are also not supported.

  • reverse(): Returns a list in which the order of all elements in the original list have been reversed.
  • tail(): Returns all but the first element in a list.

Mathematical Numeric Functions (Partially Supported)

Cypher mathematical numeric functions all operate only on numeric expressions. They will return an error if used with any other values.

  • abs(): Returns the absolute value of a number.
  • ceil(): Returns the smallest floating point number that is greater than or equal to a number and equal to a mathematical integer.
  • floor(): Returns the largest floating point number that is less than or equal to a number and equal to a mathematical integer.
  • rand(): Returns a random floating point number in the range from 0 (inclusive) to 1 (exclusive); that is [0 ; 1).
  • round(): Returns the value of a number rounded to the nearest integer.
  • sign(): Returns the sign of a number: returns 0 if the number is 0; returns -1 for any negative number; and returns 1 for any positive number.
    The sign() function is not supported in the current release.

Mathematical Logarithmic Functions (Partially Supported)

Cypher mathematical logarithmic functions all operate only on numeric expressions. They will return an error if used with any other values.

  • e(): Returns the base of the natural logarithm.
    The e() function is not supported in the current release.
  • exp(): Returns e^n where e is the base of the natural logarithm and n is the value of the argument expression.
  • log(): Returns the natural logarithm of a number.
  • log10(): Returns the common logarithm (base 10) of a number.
  • sqrt(): Returns the square root of a number.

Mathematical Trigonometric Functions (Partially Supported)

Cypher mathematical trigonometric functions all operate only on numeric expressions. They will return an error if used with any other values.

The acos, asin, atan, atan2, cot, and degrees functions are not supported in the current AnzoGraph DB release.

  • cos(): Returns the cosine of a number.
  • pi(): Returns the mathematical constant pi.
  • radians(): Converts degrees to radians.
  • sin(): Returns the sine of a number.
  • tan(): Returns the tangent of a number.

String Functions (Partially Supported)

Cypher string functions all operate only on string expressions. They will return an error if used with any other values. The exception to this rule is toString(), which also accepts numbers and boolean values as arguments.

  • left(): Returns a string containing the specified number of left-most characters of the original string.
  • lTrim(): Returns the original string with leading whitespace removed.
  • replace(): Returns a string in which all occurrences of a specified string in the original string have been replaced by another specified string.
  • reverse(): Returns a string in which the order of all characters in the original string have been reversed.
  • right(): Returns a string containing the specified number of rightmost characters of the original string.
  • rTrim(): Returns the original string with trailing white space removed.
  • split(): Returns a list of strings resulting from the splitting of the original string around matches of the given delimiter.
  • substring(): Returns a substring of the original string, beginning with a zero-based index start and length.
  • toLower(): Returns the original string in lowercase.
  • toString(): Converts an integer, float, or boolean value to a string.
  • toUpper(): Returns the original string in uppercase.
  • trim(): Returns the original string with leading and trailing white space removed.

User-defined Functions (Not Supported)

The use of user-defined functions is not supported in the current release.

Comments (Supported)

Comments may be added to queries. Single line or inline comments begin with //, and multi- line comments are delimited by /* and */. For example:

MATCH (n) RETURN n // This is an end of line comment.

Compatibility and Versioning (Not Supported)

The use of previous compatible version selection is not supported in the current release.

Related Topics