1

I am creating a table where I need to store an image translated into a numerical array ( typically float values ). While I am able to create a table with the numerical array column declared as BLOB data type, I get the following invalid request error while I try to insert the data.

Error from server: code=2200 [Invalid query] message="Invalid list literal for image_embedding of type blob"

I am trying to insert data like this :

INSERT INTO master.emp_by_embedding (site_id, emp_id, image_embedding) 
VALUES ('INDIA_01', 'AL716837', **[-1.0672206 , -1.438882  ,  1.6111488 
,  0.6600302 , -0.06482011,\n0.7914173 ,  0.78052145,  0.49402863, -0.8117229 
,  1.1979666 ,\n-0.29825854,  0.06478833,  0.998869  , -0.98645747
,  0.0959858 .... .... 0.27031496, -1.7236737 ,  1.1005085 ,  0.0200185 
, -0.9137004 ,\n-1.7611294 ,  0.08231554, -0.40587714]**) IF NOT EXISTS;

What is the right way to insert image data here ? I've tried to convert numerical data using listasblob (typeasblob) function but that doesn't work ( get an error - unknown function).

1 Answer 1

1

Raja, can you please provide the schema of your cassandra table ? Depending on the type of image_embedding syntax will be different.

describe table master.emp_by_embedding;

I see a \n characters in the table values that will probably lead to error if a real character.

Inserting list

Assuming your type is a list<double> or list<decimal> here is a working QUERY.

CREATE TABLE emp_by_embedding(
 site_id text,
 emp_id text,
 image_embedding list<double>,
 PRIMARY KEY((site_id), emp_id)
);

INSERT INTO emp_by_embedding (site_id, emp_id, image_embedding)
VALUES ('INDIA_01', 'AL716837', [-1.0672206 , -1.438882 , 1.6111488 , 0.6600302 , -0.06482011, 0.7914173 , 0.78052145, 0.49402863, -0.8117229 , 1.1979666 , -0.29825854, 0.06478833, 0.998869 , -0.98645747, 0.0959858, 0.27031496, -1.7236737 , 1.1005085 , 0.0200185 , -0.9137004 , -1.7611294 , 0.08231554, -0.40587714]) 
IF NOT EXISTS;

Inserting blob

Assuming your type is a blob (this what the error seems to tell), the expected value must be binary content not your list, you need to convert it first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.