When I try to add a new UDT type field to my cassandra table, I executed commands like:
CREATE TYPE price(
micros bigint,
currency_code varchar,
formatted_amount varchar
);
ALTER TABLE table_name ADD price frozen;
But I got an exception:
<ErrorMessage code=2000 [Syntax error in CQL query] message="line 1:38 missing EOF at '<' (...table metadata_m add price type [<]price...)">
So how to solve this problem?
I am using c* 2.1.2, cql3.2.0, cqlsh 5.0.1.
First of all, it usually helps if you provide the exception you received in your question. Fortunately for you, my sandbox has the exact same C* specs you mentioned above, so I did manage to see this exception when pasting in your code:
aploetz@cqlsh:stackoverflow> CREATE TYPE price( micros bigint, currency_code varchar, formatted_amount varchar );
aploetz@cqlsh:stackoverflow> ALTER TABLE table_name ADD price frozen;
<ErrorMessage code=2000 [Syntax error in CQL query] message="Failed parsing statement: [ALTER TABLE some_data ADD price frozen;] reason: ArrayIndexOutOfBoundsException -1">
I deducted that it was because you specified the type price
, but did not actually provide a name for the column. Also, frozen
needs to be used with the type following it in angle brackets. This worked for me:
ALTER TABLE table_name ADD myprice frozen<price>;