This document is the reference of the Sparksee openCypher Language (SCL). SCL is inspired by the OpenCypher Query Language. Inspired means that although the goal is to make SCL as close as possible to OpenCypher, differences between Sparksee’s property graph model and OpenCypher model and other technical issues make the two languages to divert in some aspects.

Differences with Open Cypher

In this section, we detail the main differences between SCL and OpenCypher

What is currently NOT supported

With the current version, the following things are not still supported:

DataTypes and Expressions

The following are the datatypes supported in expressions:

All expressions in SCL have a resulting expression datatype. Multiple expressions (typically one or two) can be combined with an operator to form another expression whose datatype will be that of the subexpressions. In general, only subexpressions of the same datatype can be combined, However, If the subexpressions are of different datatypes but these are numeric (Integer, Long, Double or Timestamp), the datatypes of the more restrictive type will be promoted to match the less restrictive datatype of the subexpressions. The promotion order is established as follows: Integer → Long → Timestamp → Double.

Operators and Functions

SCL supports the following unary and binary operators

Unary operators
Operator Description
NOT X Negates X
X IS NULL Checks if X is null
X IS NOT NULL Checks if X is not null
+ X Unary positive arithmetic operator
- X Unary negative arithmetic operator
Binary operators
Operator Description
X AND Y Binary AND
X OR Y Binary OR
X = Y X equals Y
X <> Y X different than Y
X > Y X greater than Y
X >= Y X greater or equal than Y
X < Y X smaller than Y
X <= Y X smaller or equal than Y
X + Y X plus Y
X - Y X minus Y
X * Y X times Y
X / Y X divided by Y
X % Y X modulo Y

Additionally, the following functions can be used in expressions

Operator Description
toBoolean(X) Casts X into a boolean
toInteger(X) Casts X into an Integer
toLong(X) Casts X into a Long
toTimestamp(X) Casts X into a Timestamp
toDouble(X) Casts X into a Double
toString(X) Casts X into a String
type(X) Returns the type of object X as a String
date(X) or datetime(X) Converts the string X (e.g. 2006-01-01) to a timestamp
timestamp() Returns the current timestamp

CASE expressions

SCL supports case expressions in two forms: simple and generic.

Simple CASE expressions

In simple case expressions, an expression is compared against different values until a match is found. If a match is not found, the default value is returned or NULL if such value has not been specified. The syntax is as follows

CASE test
 WHEN value THEN result
 [WHEN ...]
 [ELSE default]

where “test” is a valid expression, “value” is the value the expression is compared to, and result is the new value to set the column to. If no matches are found, the “default” value is set or NULL if it is not specified. All results must be of the same datatype. For example, a valid simple case expression is:

CASE n.color
 WHEN "Blue" THEN 1
 WHEN "Red"  THEN 2

Generic CASE expressions

Generic case expressions are similar to simple ones, with the difference that the predicate can be an arbitrary expression. As in the simple CASE expression, all results must be of the same datatype.

 WHEN predicate THEN result1
 [WHEN ...]
 [ELSE default]

For instance, we could write:

 WHEN n.age < 13 THEN "kid" 
 WHEN n.age < 18 THEN "teen"
 ELSE "adult"
Back to Index