Data Types
ArcadeDB supports several data types natively. Below is the complete table.
| Type | SQL type | Description | Java type | Minimum — Maximum | Auto-conversion from/to |
|---|---|---|---|---|---|
Boolean |
BOOLEAN |
Handles only the values True or False |
|
0 — 1 |
String |
Integer |
INTEGER |
32-bit signed Integers |
|
-2,147,483,648 — +2,147,483,647 |
Any Number, String |
Short |
SHORT |
Small 16-bit signed integers |
|
-32,768 — 32,767 |
Any Number, String |
Long |
LONG |
Big 64-bit signed integers |
|
-263 — +263-1 |
Any Number, String |
Float |
FLOAT |
Decimal numbers |
|
2-149 — (2-2-23)*2127 |
Any Number, String |
Double |
DOUBLE |
Decimal numbers with high precision |
|
2-1074 — (2-2-52)*21023 |
Any Number, String |
Datetime |
DATETIME |
Any date with the precision up to milliseconds. To know more about it, look at Managing Dates |
|
Date, Long, String |
|
Local time |
LOCAL_TIME |
A time of day without an offset, e.g. |
|
String |
|
Offset time |
OFFSET_TIME |
A time of day with a UTC offset, e.g. |
|
String |
|
Zoned datetime |
ZONED_DATETIME |
A datetime that keeps the zone or offset it was written with, e.g. |
|
String |
|
Duration |
DURATION |
An openCypher duration with months, days, seconds and nanoseconds, e.g. |
|
String |
|
String |
STRING |
Any string as alphanumeric sequence of chars |
|
||
Binary |
BINARY |
Can contain any value as byte array |
|
0 — 2,147,483,647 |
String |
Embedded |
EMBEDDED |
The Record is contained inside the owner. The contained record has no RID |
|
EmbeddedDocument |
|
Embedded list |
LIST |
The Records are contained inside the owner. The contained records have no RIDs and are reachable only by navigating the owner record |
|
0 — 41,000,000 items |
String |
Embedded map |
MAP |
The Records are contained inside the owner as values of the entries, while the keys can only be Strings. The contained records have no RIDs and are reachable only by navigating the owner Record |
|
0 — 41,000,000 items |
|
Link |
LINK |
Link to another Record. It’s a common one-to-one relationship |
|
1:-1 — 32767:263-1 |
String |
Byte |
BYTE |
Single byte. Useful to store small 8-bit signed integers |
|
-128 — +127 |
Any Number, String |
Decimal |
DECIMAL |
Decimal numbers without rounding |
|
Any Number, String |
|
Vector |
ARRAY_OF_? |
Vector of scalar types: SHORTS, INTEGERS, LONGS, FLOATS, DOUBLES. A full type is for example then ARRAY_OF_FLOATS |
Tuples |
Embedded types, like EMBEDDED (document), (embedded) LIST, and (embedded) MAP are non-scalar types.
|
A vector type can be either LIST OF SHORT|INTEGER|LONG|FLOAT|DOUBLE or ARRAY_OF_SHORTS|INTEGERS|LONGS|FLOATS|DOUBLES.
|
An ARRAY_OF_FLOATS or ARRAY_OF_DOUBLES value is stored fixed-width: the element count followed by the raw little-endian IEEE-754 elements, 4 bytes per float and 8 per double (since v26.11.1). Before, each element was written as a zigzag varint of its bit pattern, 5 bytes per float and 9 to 10 per double. A record holding a 1536-dimension float embedding shrinks from about 7,695 to about 6,150 bytes, so 9 such records fit a 64 KiB bucket page instead of 7, about 22% less disk and page cache. Existing records need no migration: the old form is still read, and an update rewrites the value in the new form. Once a database holds records in the new form, a build older than 26.11.1 cannot read them (see Upgrade). In an HA cluster the new form is written only once every peer advertises the fixed-width-float-arrays capability, so a rolling upgrade keeps writing the old form until the last node runs 26.11.1 (see High Availability).
|
A declared ARRAY_OF_SHORTS|INTEGERS|LONGS|FLOATS|DOUBLES property takes a list or an array of numbers, primitive (float[], int[], …) or boxed (Float[], Object[], …), and converts it to the declared element type, refusing an item out of its range. Since v26.11.1 any other value is refused with an error naming the property: a scalar (embedding = 0.5), a string ('[0.1, 0.2]'), a map, a list with a null or non-numeric item, or a number the element type cannot hold (Double.MAX_VALUE for an ARRAY_OF_FLOATS, which used to become Infinity). Before, such a value was stored as it came, and depending on whether a vector index on the property already existed, the write failed or the row was silently missing from an index created afterwards. Records written before the upgrade are read back unchanged.
|
An equality lookup (=, <>, IN) on a FLOAT or DOUBLE property converts the operand to the property’s type, with or without an index. A FLOAT holding 0.1 is therefore found by the double 0.10000000149011612 (what you get by reading the FLOAT back as a double), and a DOUBLE is found by the BigDecimal that rounds to it. Ordering (<, >) is unchanged and reads a FLOAT by its decimal value, so a value can satisfy both = and < against the same operand.
|
A write to a declared property is refused, with an error naming the property, when the value cannot be held by the type: a boolean, list, map or date for a numeric property, an empty string for a numeric property, a number outside the 64-bit range for a LONG (or a finite number that overflows a FLOAT or DOUBLE), an empty or digit-only string for a DATETIME, a string for a BINARY, a non-link value for a LINK, or an array for a STRING. A STRING holding a lone UTF-16 surrogate (for example "\uD83D", which cannot be encoded as UTF-8) is refused with a validation error instead of being stored as ?. Such a value is never stored as NULL, 0 or as a value of another type, with or without an index. A number written to a BOOLEAN is false only when it is 0.
|
A number with a fraction written to a BYTE, SHORT, INTEGER or LONG property is judged by its value without the fraction (dropped toward zero): 127.5 is a valid BYTE and is stored as 127, while 128.5 is refused. The same holds at both ends of the LONG range for a DECIMAL: 9223372036854775807.5 is stored as 9223372036854775807 and -9223372036854775808.5 as -9223372036854775808, while 9223372036854775808 and -9223372036854775809 are refused. (Since v26.12.1, issue #13003) Before, a LONG property refused a DECIMAL less than one unit beyond either end of its range, which a BYTE, SHORT or INTEGER property accepted at its own ends.
|
A java.math.BigInteger written to a property with no declared type keeps its exact value: inside the 64-bit range it is stored as an INTEGER or LONG, outside it as a DECIMAL (it reads back as a BigDecimal with the same digits), never as a rounded DOUBLE.
|
A Java enum constant written to a property with no declared type, or put in a list, set or map, is stored as a STRING holding its text (toString(), the same text a declared STRING property gets) and reads back as a String, so WHERE color = 'RED' finds it. (Since v26.12.1, issue #12624) Before, the property was left out of the record with only a warning in the log, and a list, set or map element became null. A map whose keys would be stored as the same text, such as an enum key RED and a String key 'RED', is refused with an error instead of keeping only one of the two values.
|
A Java Character (char) written to a property with no declared type, or put in a list, set or map, is stored as a one-character STRING and reads back as a String, the same text a declared STRING property gets, so WHERE c = 'x' finds it. From Gremlin, a char sent by a groovy script or a driver is stored the same way, and has('c', 'x') matches the string 'x'. (Since v26.12.1, issue #12021) Before, the property was left out of the record with only a warning in the log, and a list, set or map element became null. A map whose keys would be stored as the same text, such as a Character key 'k' and a String key "k", is refused with an error instead of keeping only one of the two values.
|
Equality lookups give the same answer with or without an index. Two DECIMAL values are equal when they have the same numeric value, whatever their scale (19.9 equals 19.90). A DATETIME property is matched by a java.time.Instant, ZonedDateTime or OffsetDateTime of the same moment. A BOOLEAN property is matched by true/false as a string or by a number (0 is false, anything else is true); an operand that does not read as a boolean matches nothing.
|
A negative zero is the same value as zero in an equality lookup: a FLOAT or DOUBLE property holding -0.0 is found by a 0 of any numeric type, a BYTE or SHORT included (WHERE f = :x with a Short or Byte parameter, or WHERE f = s against a SHORT property), with or without an index. (Since v26.12.1, issue #12984) Before, a scan did not find a FLOAT -0.0 for a BYTE or SHORT operand while an index did.
|
In SQL, a DECIMAL property compared with an infinity or a NaN (what 1.0 / 0, -1.0 / 0 and 0.0 / 0 produce, or a Double.POSITIVE_INFINITY passed as a parameter) is ordered as for any other numeric property, with or without an index: negative infinity is below every number, positive infinity and NaN above. So WHERE dec < (1.0 / 0) and WHERE dec > (-1.0 / 0) select every row that has a value, WHERE dec > (1.0 / 0) selects none, and BETWEEN agrees with >= and ⇐. An equality against an infinity or a NaN matches no row, and a decimal beyond the DOUBLE range (1E+400) still orders below positive infinity. (Since v26.12.1, issue #12694) Before, such a comparison failed with a NumberFormatException in a scan, matched no row through an index, and a BETWEEN with such a bound selected no row in a scan.
|
In SQL, a DECIMAL property compared with a boolean is neither equal to it, above it nor below it, as for the other numeric types and with or without an index: WHERE dec > true, dec >= true and dec < true select no row, and dec <> true selects every row that has a value. (Since v26.12.1, issue #12936) Before, a scan ordered every DECIMAL above true (dec > true selected every row) while an index selected none.
|
When serializing floating point types FLOAT and DOUBLE to JSON, NaN, Inf, and -Inf are cast to null, wherever they appear, including inside lists and arrays.
|
Embedded MAP vs EMBEDDED Document
A MAP type and an EMBEDDED type are both a hierarchy of key-value pairs (think JSON);
but the EMBEDDED type needs to know which document type it is an instance of.
Hence, to embed a document, a document type needs to be declared beforehand,
such that upon embedding validity of constrains (if existing) can be checked.
The embedded type is taken from either of two places:
-
a
@typeproperty in the value’s top-level, naming an existing document type, or -
the property’s own declared embedded type, when the property was created with one (
CREATE PROPERTY Person.address EMBEDDED OF Address).
If the property declares an embedded type, a plain map is enough and you do not have to repeat @type:
person.set("address", Map.of("city", "Rome"));
A @type in the value still takes precedence where present, which is how you store a subtype of the declared one.
If neither is available, the value is rejected.