Phoenix Language Reference

Phoenix is a SQL layer over HBase delivered as an embedded JDBC driver. The top level commands, SQL syntax, built-in functions, and supported data types are documented in the separate tabs below.


Index

INTEGER Type
UNSIGNED_INT Type
BIGINT Type
UNSIGNED_LONG Type
DECIMAL Type
BOOLEAN Type
TIME Type
DATE Type
TIMESTAMP Type
VARCHAR Type
CHAR Type
BINARY Type
VARBINARY Type

INTEGER Type

INTEGER
INTEGER

Possible values: -2147483648 to 2147483647.

Mapped to java.lang.Integer. The binary representation is a 4 byte integer with the sign bit flipped (for binary comparability).

Example:

INTEGER

UNSIGNED_INT Type

UNSIGNED_INT
UNSIGNED_INT

Possible values: 0 to 2147483647. Mapped to java.lang.Integer. The binary representation is a 4 byte integer, matching the HBase.toBytes(int) method.

Example:

UNSIGNED_INT

BIGINT Type

BIGINT
BIGINT

Possible values: -9223372036854775808 to 9223372036854775807. Mapped to java.lang.Long. The binary representation is an 8 byte long with the sign bit flipped (for binary comparability).

Example:

BIGINT

UNSIGNED_LONG Type

UNSIGNED_LONG
UNSIGNED_LONG

Possible values: 0 to 9223372036854775807. Mapped to java.lang.Long. The binary representation is an 8 byte integer, matching the HBase.toBytes(long) method.

Example:

UNSIGNED_LONG

DECIMAL Type

DECIMAL
DECIMAL

Data type with fixed precision and scale. The maximum precision is 18 digits. Mapped to java.math.BigDecimal. The binary representation is binary comparable, variable length format. When used in a row key, it is terminated with a null byte unless it is the last column.

Example:

DECIMAL

BOOLEAN Type

BOOLEAN
BOOLEAN

Possible values: TRUE and FALSE.

Mapped to java.lang.Boolean. The binary representation is a single byte with 0 for false and 1 for true

Example:

BOOLEAN

TIME Type

TIME
TIME

The time data type. The format is yyyy-MM-dd hh:mm:ss, with both the date and time parts maintained. Mapped to java.sql.Time. The binary representation is an 8 byte long (the number of milliseconds from the epoch).

Example:

TIME

DATE Type

DATE
DATE

The date data type. The format is yyyy-MM-dd hh:mm:ss, with both the date and time parts maintained to a millisecond accuracy. Mapped to java.sql.Date. The binary representation is an 8 byte long (the number of milliseconds from the epoch).

Example:

DATE

TIMESTAMP Type

TIMESTAMP
TIMESTAMP

The timestamp data type. The format is yyyy-MM-dd hh:mm:ss[.nnnnnnnnn]. Mapped to java.sql.Timestamp with an internal representation of the number of nanos from the epoch. The binary representation is 12 bytes: an 8 byte long for the epoch time plus a 4 byte integer for the nanos.

Example:

TIMESTAMP

VARCHAR Type

VARCHAR  [ ( precisionInt ) ]
VARCHAR
 
( precisionInt )

A variable length String with an optional max byte length. The binary representation is UTF8 matching the HBase Bytes.toBytes(String) method. When used in a row key, it is terminated with a null byte unless it is the last column.

Mapped to java.lang.String.

Example:

VARCHAR
VARCHAR(255)

CHAR Type

CHAR ( precisionInt )
CHAR ( precisionInt )

A fixed length String with single-byte characters. The binary representation is UTF8 matching the HBase Bytes.toBytes(String) method.

Mapped to java.lang.String.

Example:

CHAR(10)

BINARY Type

BINARY ( precisionInt )
BINARY ( precisionInt )

Raw fixed length byte array.

Mapped to byte[].

Example:

BINARY

VARBINARY Type

VARBINARY
VARBINARY

Raw variable length byte array.

Mapped to byte[].

Example:

VARBINARY