Blob data type in Cassandra - Cassandra / CQL Tutorial

Blob data type in Cassandra Query Language ( CQL)

Often we have to save mixed data such as strings and integers together and large amount of data. For that Cassandra has Blob data type which can store max of 2 GB data. Let's create a table by using Cassandra Query Language ( CQL) with column name resume of blob type by using below statement.
CQLSH:techbrotherstutorials>CREATE TABLE tbs 
             ( 
                          id INT PRIMARY KEY, 
                          NAME TEXT, 
                          resume BLOB 
             );

I am inserting small data, In real when you will be using blob when you need to insert large data. To insert the data into Blob type column, you have to convert the data to blob by using function TypeAsBlob. In my case as I am saving text data, I will use TextAsBlob. If you need to save Bigint then you will use BigIntAsBlob function.
CQLSH:techbrotherstutorials>INSERT INTO tbs 
            ( 
                        id, 
                        NAME, 
                        resume 
            ) 
            VALUES 
            ( 
                        1, 
                        'Doe John', 
                        Textasblob('My detail resume xx98808944') 
            );

Let's insert second record in blob data type column
CQLSH:techbrotherstutorials>INSERT INTO tbs 
            ( 
                        id, 
                        NAME, 
                        resume 
            ) 
            VALUES 
            ( 
                        2, 
                        'Mike', 
                        Textasblob('Mike''s Resume is good for developer position') 
            );

Now if you will try to read the data by using CQL Select , straight from the table, you will get hexa decimal data for blob column. To display data as string and number the way you have saved it , you need to use function BlobtoType. In my case, I will use BlobtoText, if you have saved Bigint data into blob data column, you will be using BlobtoBigint function.

CQLSH:techbrotherstutorials>SELECT id, 
       NAME, 
       Blobastext(resume) AS resume 
FROM   tbs;