CQL for Cassandra 2.x

Blob type

The Cassandra blob data type represents a constant hexadecimal number defined as 0[xX](hex)+ where hex is an hexadecimal character, such as [0-9a-fA-F]. For example, 0xcafe.

Blob conversion functions

These functions convert the native types into binary data (blob):
  • typeAsBlob(type)
  • blobAsType
For every native, nonblob type supported by CQL, the typeAsBlob function takes a argument of type type and returns it as a blob. Conversely, the blobAsType function takes a 64-bit blob argument and converts it to a bigint value.

This example shows how to use bitintAsBlob:

CREATE TABLE bios ( user_name varchar PRIMARY KEY, 
   bio blob

INSERT INTO bios (user_name, bio) VALUES ('fred', bigintAsBlob(3));
 user_name | bio
      fred | 0x0000000000000003

This example shows how to use blobAsBigInt.

ALTER TABLE bios ADD id bigint;

INSERT INTO bios (user_name, id) VALUES ('fred', blobAsBigint(0x0000000000000003));


 user_name | bio                | id
      fred | 0x0000000000000003 |  3