Skip to main content
Version: 6.0-SNAPSHOT

SQL Data Types

Hazelcast supports a subset of SQL data types. Each data type is mapped to a Java class, which represents the type's value in Hazelcast.

Type NameSupported Casting TypesJava Class
BOOLEANVARCHAR, BOOLEAN, OBJECTjava.lang.Boolean
VARCHARAll typesjava.lang.String
TINYINTVARCHAR, BOOLEAN, SMALLINT, INTEGER, BIGINT, DECIMAL, REAL, DOUBLE, OBJECTjava.lang.Byte
SMALLINTVARCHAR, SMALLINT, INTEGER, BIGINT, DECIMAL, REAL, DOUBLE, OBJECTjava.lang.Short
INTERVALN/ACustom
JSONVARCHARHazelcastJsonValue
INTEGERVARCHAR, SMALLINT, INTEGER, BIGINT, DECIMAL, REAL, DOUBLE, OBJECTjava.lang.Integer
BIGINTVARCHAR, SMALLINT, INTEGER, BIGINT, DECIMAL, REAL, DOUBLE, OBJECTjava.lang.Long
DECIMALVARCHAR, SMALLINT, INTEGER, BIGINT, DECIMAL, REAL, DOUBLE, OBJECTjava.math.BigDecimal
REALVARCHAR, SMALLINT, INTEGER, BIGINT, DECIMAL, REAL, DOUBLE, OBJECTjava.lang.Float
DOUBLEVARCHAR, SMALLINT, INTEGER, BIGINT, DECIMAL, REAL, DOUBLE, OBJECTjava.lang.Double
DATEVARCHAR, DATE, TIME, TIMESTAMP, TIMESTAMP WITH TIME ZONE, OBJECTjava.time.LocalDate
TIMEVARCHAR, DATE, TIME, TIMESTAMP, TIMESTAMP WITH TIME ZONE, OBJECTjava.time.LocalTime
TIMESTAMPVARCHAR, DATE, TIME, TIMESTAMP, TIMESTAMP WITH TIME ZONE, OBJECTjava.time.LocalDateTime
TIMESTAMP WITH TIME ZONEVARCHAR, DATE, TIME, TIMESTAMP, TIMESTAMP WITH TIME ZONE, OBJECTjava.time.OffsetDateTime
OBJECTAll typesAny Java class

Casting and Data Type Conversion​

To convert one data type to another (also known as casting), you can use the CAST(expression AS type_name) function.

Numeric Literals​

When numeric literals are assigned SQL types:

  1. Integers, e.g., 1 and 42, receive the narrowest possible among TINYINT, SMALLINT, INTEGER, BIGINT and DECIMAL.
  2. Floating-point numbers, e.g., 1.2 and 4.2, receive DECIMAL.
  3. Scientific notation (exponential form), e.g., 1e1 or 4.2e2, receives DOUBLE.

As you realized, integers are optimized for storage, whereas floating-point numbers are not subject to such optimization. This is because REAL and DOUBLE cannot exactly represent all decimal numbers (see IEEE 754), and exactness cannot be compromised for financial applications. Finally, because of its rare usage, scientific notation is not optimized for storage, i.e., not tried to narrow to REAL.

Numbers that are represented in scientific notation and out of range for DOUBLE will cause overflow and be interpreted as ∞ or -∞. For example, 1.8e+308 is greater than the largest possible finite value of DOUBLE, which is 1.7976931348623157e+308, and so it is only valid in the form 18000…​0.