5

I attempted to create a table with counter as one of the column type in cassandra but getting the following error:

ConfigurationException: ErrorMessage code=2300 [Query invalid because of configuration issue] message="Cannot add a counter column (transaction_count) in a non counter column family"

My table schema is as follows:

CREATE TABLE MARKET_DATA_TRANSACTION_COUNT (
TRADE_DATE TIMESTAMP,      
SECURITY_EXCHANGE TEXT,
PRODUCT_CODE TEXT,
SYMBOL TEXT,
SPREAD_TYPE TEXT,     
USER_DEFINED TEXT,
PRODUCT_GUID TEXT,
CHANNEL_ID INT,  
SECURITY_TYPE TEXT,
INSTRUMENT_GUID TEXT,
SECURITY_ID INT,   
TRANSACTION_COUNT COUNTER,
PRIMARY KEY (TRADE_DATE));
Andremoniy
  • 34,031
  • 20
  • 135
  • 241
Pradnya Alchetti
  • 165
  • 3
  • 12
  • Possible duplicate of [Cassandra Non-Counter Family](http://stackoverflow.com/questions/19596618/cassandra-non-counter-family) – Andremoniy Apr 07 '17 at 08:49

2 Answers2

4

That's a limitation of the current counter implementation. You can't mix counters and regular columns in the same table. So you need a separate table for counters.

They are thinking of removing this limitation in Cassandra 3.x. See this Jira ticket.

Jim Meyer
  • 9,275
  • 1
  • 24
  • 49
3

This is not exactly the answer to the question, might help some people with the similar error.

If you can make other columns as PRIMARY KEY then its possible.

Eg: CREATE TABLE rate_data (ts varchar, type varchar, rate counter, PRIMARY KEY (ts, type));
naren
  • 14,611
  • 5
  • 38
  • 45
  • the question has a different primary key which is not a counter , yet the error –  Jul 27 '20 at 09:22