ConfigurationException: Invalid type int for column above_size: Cannot mix counter and non counter columns in the same table

Viewed 73

Why I get this error message if I create this table ?

items_by_name
    item_id uuid
    user_id uuid
    name TEXT
    image VARCHAR
    desc TEXT
    price DECIMAL
    category TEXT
    trouser_size INT
    shoe_size INT
    above_size INT
    color TEXT,
    liked_user_id INT,
    like_count counter,
    PRIMARY KEY (name, item_id)

........................... .......................... ........................... ............................. .............................

1 Answers

Tables with counters are handled specially in Cassandra, and as result, you may have non-counter types only as part of the primary key, but not as regular columns. From documentation:

A table that contains a counter can only contain counters. In other words, either all the columns of a table outside the PRIMARY KEY have the counter type, or none of them have it.

There are also other limitations - see documentation.

In your case, you will need to have two tables - one for counters, and one - for the non-counter types. Just use the same primary key for both tables.

Related