Overview
Basic data types
Flavius support the following data types:
Data Type | Alias | Description | Storage Size | Min Value | Max Value |
---|---|---|---|---|---|
BOOLEAN | BOOL | Boolean | 1 Byte | N/A | N/A |
BIGINT | - | 64-bit signed integer | 8 Bytes | -9223372036854775808 | 9223372036854775807 |
DOUBLE | - | Double precision floating point number | 8 Bytes | -1.7976931348623157E+308 | 1.7976931348623157E+308 |
VARCHAR | - | UTF-8 valid string | N/A | N/A | N/A |
TIME | - | Time with nanosecond precision | 8 Bytes | ’00:00:00.000000000' | '23:59:59.999999999’ |
DATE | - | Date in the format ‘YYYY-MM-DD’ | 4 Bytes | ’0001-01-01' | '9999-12-31’ |
DATETIME | - | Date + Time with nanosecond precision | 8 Bytes | ’1677-09-21T00:12:44.999999999' | '2262-04-11T23:47:16.854775807’ |
TIMESTAMP | - | Date + Time with nanosecond precision + timezone | 8 Bytes | ’1677-09-21T00:12:44.999999999+0000' | '2262-04-11T23:47:16.854775807+0000’ |
Structured data types
Flavius support the following structured data types:
Data Type | Alias | Description | Example |
---|---|---|---|
ARRAY | LIST | Collection of values of the same type | [1, 2, 3] , ['a', 'b', 'c'] , [true, false] |
STRUCT | - | Collection of values of different types | {name: 'John', age: 30, active: true} |
Graph specific data types
Flavius support the following graph specific data types:
Data Type | Alias | Description | Example |
---|---|---|---|
Vertex | - | Vertex/Node structure, has two built in fields, __id__ of BIGINT type to represent the internal id of this node, __label__ of VARCHAR type describing the associated node label. | {name:'John', age: 30, active: true, __id__ : 12345, __label__ : } |
Edge | - | Edge/Relationship structure, has three built-in fields: __srcid__ of BIGINT type representing the source vertex ID, __dstid__ of BIGINT type representing the destination vertex ID, and __label__ of VARCHAR type describing the edge label | {__srcid__: 1, __dstid__: 2, __label__: "KNOWS", since: "2023"} |
Casting
Casting rules
Flavius supports implicit and explicit type casting between different data types. The following table shows the supported type casting operations:
From Type | To Type | Implicit | Explicit | Notes |
---|---|---|---|---|
BOOLEAN | VARCHAR | ✓ | ✓ | Converts to ‘true’ or ‘false’ string |
BOOLEAN | BIGINT | ✓ | ✓ | Converts to 1 (true) or 0 (false) |
BOOLEAN | DOUBLE | ✓ | ✓ | Converts to 1.0 (true) or 0.0 (false) |
BIGINT | BOOLEAN | ✗ | ✓ | Converts to false (0) or true (other values) |
BIGINT | DOUBLE | ✓ | ✓ | May lose precision |
BIGINT | VARCHAR | ✗ | ✓ | Converts to string representation |
DOUBLE | BOOLEAN | ✗ | ✓ | Converts to false (0.0) or true (other values) |
DOUBLE | BIGINT | ✗ | ✓ | May lose precision |
DOUBLE | VARCHAR | ✗ | ✓ | Converts to string representation |
VARCHAR | BOOLEAN | ✗ | ✓ | Only ‘true’/‘false’ (case-insensitive) |
VARCHAR | BIGINT | ✗ | ✓ | Must be valid integer string |
VARCHAR | DOUBLE | ✗ | ✓ | Must be valid numeric string |
VARCHAR | DATE | ✗ | ✓ | Must be in format ‘YYYY-MM-DD’ |
VARCHAR | TIME | ✗ | ✓ | Must be in format ‘HH:MM:SS[.nnnnnnnnn]‘ |
VARCHAR | DATETIME | ✗ | ✓ | Must be in format ‘YYYY-MM-DD HH:MM:SS[.nnnnnnnnn]‘ |
VARCHAR | TIMESTAMP | ✗ | ✓ | Must be in format ‘YYYY-MM-DD HH:MM:SS[.nnnnnnnnn][+-]HH:MM’ or ‘YYYY-MM-DD HH:MM:SS[.nnnnnnnnn][Z]’ , example: 2024-12-23 23:49:23+0800 |
TIME | VARCHAR | ✗ | ✓ | Converts to ‘YYYY-MM-DD’ format |
DATE | VARCHAR | ✗ | ✓ | Converts date to string in ‘YYYY-MM-DD’ format |
DATE | DATETIME | ✓ | ✓ | Adds default time component ‘00:00:00.000000000’ to date |
DATE | TIMESTAMP | ✓ | ✓ | Adds default time ‘00:00:00.000000000’ and UTC timezone to date |
DATETIME | VARCHAR | ✗ | ✓ | Converts datetime to string in ‘YYYY-MM-DD[ T]HH:MM:SS[.nnnnnnnnn]’ format |
DATETIME | DATE | ✗ | ✓ | Extracts date part only |
DATETIME | TIMESTAMP | ✓ | ✓ | Adds UTC timezone |
TIMESTAMP | VARCHAR | ✗ | ✓ | Converts timestamp to string in ‘YYYY-MM-DD[ T]HH:MM:SS[.nnnnnnnnn][Z]’ format |
TIMESTAMP | DATE | ✗ | ✓ | Extracts date part only |
TIMESTAMP | DATETIME | ✗ | ✓ | Removes timezone information |
Explicit casting by CAST
expression
Syntax
CAST(<value> AS <type>)
Example:
-- Convert string to date
CAST('2023-01-01' AS DATE);
-- Convert boolean to integer
CAST(true AS BIGINT);
-- Convert datetime to timestamp
CAST('2023-01-01 12:00:00' AS TIMESTAMP);
-- Convert array of strings to array of integers
CAST(['1', '2', '3'] AS ARRAY<BIGINT>);
Last updated on