DEV Community

Abhi-Kmr2046
Abhi-Kmr2046

Posted on

Apache AGE Datatypes

Apache AGE uses its own custom data type called agetype, which is a super set of Json and a custom implementation of JsonB. It is the only data type returned by AGE.

Simple Data Types

  • Null: It represents missing or undefined values. Most expressions that take null as input will produce null. Null is not equal to null. Not knowing two values does not imply that they are the same value. So the expression null = null yields null and not true.

  • Integer: It stores whole numbers and it is a 64 bit field that stores values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. The smallint type is generally used only if disk space is at a premium. The bigint type is designed to be used when the range of the integer type is insufficient.

SELECT *
FROM cypher('graph', $$
    RETURN 1
$$) AS (result agtype);

Enter fullscreen mode Exit fullscreen mode
  • Float: The data type float is an inexact, variable-precision numeric type, conforming to the IEEE-754 Standard. Values that are too large or too small will cause an error. Rounding might take place if the precision of an input number is too high. Numbers too close to zero that are not representable as distinct from zero will cause an underflow error. It also supports values Infinity, -Infinity and Nan.
SELECT *
FROM cypher('graph', $$
    RETURN 1.0
$$) AS (result agtype);


Enter fullscreen mode Exit fullscreen mode
  • Numeric: The type numeric can store numbers with a very large number of digits. It is especially recommended for storing monetary amounts and other quantities where exactness is required. Calculations with numeric values yield exact results where possible, e.g., addition, subtraction, multiplication. However, calculations on numeric values are very slow compared to the integer types, or to the floating-point type.
SELECT *
FROM cypher('graph', $$
    RETURN 1.0::numeric
$$) AS (result agtype);

Enter fullscreen mode Exit fullscreen mode
  • Bool: AGE provides the standard Cypher type boolean. The boolean type can have several states: “true”, “false”, and a third state, “unknown”, which is represented by the Agtype null value. Boolean constants can be represented in Cypher queries by the keywords TRUE, FALSE, and NULL.
SELECT *
FROM cypher('graph', $$
    RETURN TRUE
$$) AS (result agtype);

Enter fullscreen mode Exit fullscreen mode
  • String: Single (') quotes are used to identify a string. The output will uses double (") quotes. AGE type strings can also contain escape sequences, for example, \t, \b, \n.
SELECT *
FROM cypher('graph', $$
    RETURN 'Example String'
$$) AS (result agtype);

Enter fullscreen mode Exit fullscreen mode

These are the Simple Data Types used in Apache AGE. There are also Composite Data Types which includes List and Maps.

Top comments (0)