3.3.1 Mapping between CQL data types and Java data types

CQL data types are mapped to Java data types.

The following table shows the mapping between CQL data types and Java data types.

Table 3-5 Mapping between CQL data types and Java data types

ClassCQL data typeData formatJava data typeData rangeRemarks
Numeric dataINT[EGER]Integer, 4 bytesInteger class-2,147,483,648 through 2,147,483,647--
SMALLINTInteger, 2 bytesShort class-32,768 through 32,767--
TINYINTInteger, 1 byteByte class-128 through 127--
BIGINTInteger, 8 bytesLong class-9,223,372,036,854,775,808 through 9,223,372,036,854,775,807--
DEC[IMAL]['('m')']#1Decimal formatjava.math.BigDecimal class-1038+1 through 1038-1Decimal number whose precision (the total number of digits) is m digits (not including the + or - sign).
m is a positive integer in the range of 1 [Figure] m[Figure] 38. If m is omitted, 15 is assumed.
NUMERIC['('m')']#1
REALReal number, 4 bytesFloat class
  • -3.402823466​E+38 through -1.175494351​E-38
  • 0
  • 1.175494351​E-38 through 3.402823466​E+38
Data cannot be input using an exponential expression
FLOATReal number, 8 bytesDouble class
  • -1.7976931348623157​E+308 through -2.2250738585072014​E-308
  • 0
  • 2.2250738585072014​E-308 through 1.7976931348623157​E+308
Data cannot be input using an exponential expression
DOUBLE
Character dataCHAR[ACTER]['('n')']Fixed-length character string (with n characters)java.lang.String class1 to 255 charactersn is a positive integer in the range of 1 [Figure] n[Figure] 255. If n is omitted, 1 is assumed. The necessary number of spaces are added to fill the string. If the data length exceeds the specified number of characters n, an error occurs.
VARCHAR'('n')'Variable-length character string (with the maximum of n characters)1 to 32,767 charactersn is a positive integer in the range of 1 [Figure] n[Figure] 32,767. Spaces for filling the string are not added. If the data length exceeds the specified number of characters n, an error occurs.
Date dataDATE#2Date (year-month-day)java.sql.Date classYYYYMMDD
YYYY:
0001 to 9999 (Year)
MM:
01 to 12 (Month)
DD:
01 to the last day of the applicable month (Day)
--
Time dataTIME#2Time (hour-minutes-seconds)java.sql.Time classhhmmss
hh:
00 to 23 (hour)
mm:
00 to 59 (minutes)
ss:
00 to 59 (seconds)
--
Timestamp dataTIMESTAMP['('p')']#2Date and time (year-month-day + hour-minutes-seconds + nanoseconds)java.sql.Timestamp classYYYYMMDDhhmmss[nn....n]
YYYY:
0001 to 9999 (Year)
MM:
01 to 12 (Month)
DD:
01 to the last day of the applicable month (Day)
hh:
00 to 23 (hour)
mm:
00 to 59 (minutes)
ss:
00 to 59 (seconds)
nn....n:
p-digit fractional seconds (n: 0 to 9)
p is a positive integer. n is in the range of 0 [Figure] n[Figure] 9. If p is omitted, 3 is assumed.
If the number of digits in p is 3, 6, or 9, time is being specified in 1-millisecond, 1-microsecond, or 1-nanosecond units, respectively. If the specified data exceeds p, an error occurs.
Legend:
Class: Classification
--: Not applicable
#1
For notes related to the DECIMAL and NUMERIC types, see 3.3.2 Notes on the DECIMAL and NUMERIC types.
#2
For data of the DATE, TIME, and TIMESTAMP types, be careful not to specify out-of-range values. If out-of-range values are specified for these data types, no error occurs, but there is a risk that an unintended date might execute an undesired process.

Reference note
Mapping between CQL data types and Java data types follows the JDBC API, which defines the mapping between SQL data types and Java data types.