Cypher Types, Lists, and Maps

This section describes AnzoGraph compatibility with the Cypher Language specification for Cypher types, lists, and maps.

Types (Partially Supported)

List, Map, and Path data types are not currently supported in AnzoGraph.

The Cypher standard specifies data type support in three different categories:

  • Property types
  • Structural types
  • Composite types

Property Types

Property types include the following:

  • NUMBER – Abstract type, which has INTEGER or FLOAT as subtypes.
  • STRING – Unicode string type.
  • BOOLEAN – true and false values. (Cypher uses ternary logic in the WHERE clause; in addition to true and false values, a third state is a null ternary value indicating an indeterminate state.)

Each property type can be returned from Cypher queries, used as parameters, stored as properties, or constructed with Cypher literals.

Structural Types

Structural types include the following:

  • NODE – comprised of ID, label(s), or a map (of properties).
  • RELATIONSHIP – comprised of an ID, type, map (of properties), or the ID of the start and end nodes.
  • PATH – An alternating sequence of nodes and relationships.

The PATH type is not supported in the current AnzoGraph release.

Each structural type can be returned from Cypher queries. Structural types cannot be used as parameters, stored as properties, or constructed with Cypher literals.

Nodes, relationships, and paths are returned as a result of pattern matching. Labels are not values but are a form of pattern syntax.

Composite Types

Composite types include:

  • LIST OF T — is a heterogeneous, ordered collections of values, each of which has any property, structural or composite type T.
  • MAP is a heterogeneous, unordered collections of key-value pairs, where the key is a string and the value has any property, structural, or composite type.

LIST and MAP types are not supported in the current AnzoGraph release.

Composite types can be returned from Cypher queries, used as parameters. or constructed with Cypher literals.

Composite values can also contain null. Composite types cannot be stored as properties.

Type Coercions (Partially Supported)

There are two type coercions described in the Cypher language specification:

  • LIST OF NUMBER to LIST OF FLOAT
  • INTEGER to FLOAT

Since the LIST type is not supported, only the INTEGER to FLOAT coercion is supported in the current AnzoGraph release.

Lists (Not Supported)

Cypher lists are not supported in the current AnzoGraph release.

The Cypher specification provides information about specifying lists in queries and returning lists in results. A literal list is created by using brackets and separating all elements in the list with commas. For example:

RETURN [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] AS list

In addition, the range function can be used to access individual elements in a list.

The Cypher language specification also describes two syntactic constructs for lists, List Comprehension and Pattern Comprehension.

  • List comprehension is a syntactic construct available in Cypher for creating a list based on existing lists. It follows the form of the mathematical set-builder notation (set comprehension) instead of the use of map and filter functions.
  • Pattern comprehension is a syntactic construct available in Cypher for creating a list based on matching a pattern. A pattern comprehension will match the specified pattern just like a normal MATCH clause, with predicates (just like in a normal WHERE clause), but it will yield a custom projection.

Maps (Not Supported)

The Cypher specification provides information about constructing maps using Cypher and constructing map projections from nodes, relationships, and other map values.

Map functionality is not supported in the current AnzoGraph release.

Working with Null (Supported)

In Cypher, null is used to represent missing or undefined values. Conceptually, null represents a missing or unknown value and it is treated somewhat differently from other values. For example, obtaining a property value from a node that does not have that property value defined produces a null. Most expressions that take null as input will also produce a null result. This includes boolean expressions that are used as predicates in the WHERE clause.

Logical Operations with Null

The logical operators (AND, OR, XOR, NOT) treat null as the unknown value of three-valued logic (true, false, and unknown). In this case, null values are interpreted as being false.

The IN Operator and Null

If Cypher determines that a value or element exists in a list, the result returned will be true. Any list that contains a null and doesn’t have an element that matches will return null. Otherwise, the result returned will be false.

Lists are not supported in the current AnzoGraph release.

Expressions That Return Null

The following expressions will return null values:

  • Accessing a property that does not exist on a node or relationship, that is, n.missingProperty
  • Comparisons where either side of the expression is null, for example: 1 < null
  • Arithmetic expressions containing null, for example: 1 + null
  • Function calls where any arguments are null, for example: sin(null)
Related Topics