Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra valid column names

Tags:

cassandra

cql

I'm creating a api which will work on either mongo or cassandra, for that reason I'm using '_id' as a column name.

This should be a valid name according to the docs:

Keyspace, column, and table names created using CQL can only contain alphanumeric and underscore characters. User-defined data type names and field names, user-defined function names, and user-defined aggregate names created using CQL can only contain alphanumeric and underscore characters. If you enter names for these objects using anything other than alphanumeric characters or underscores, Cassandra will issue an invalid syntax message and fail to create the object.

However, when I run this statement:

CREATE TABLE users(_id: bigint, entires: map<timestamp, text>, PRIMARY KEY(_id));

I return the following error:

Invalid syntax at line 1, char 20

Is it possible to use underscores in column names?

like image 563
byrdr Avatar asked Aug 20 '15 19:08

byrdr


1 Answers

Underscores in columns names? Yes. Column names starting with underscores? No.

From the CREATE TABLE documentation:

Valid table names are strings of alphanumeric characters and underscores, which begin with a letter.

like image 83
Aaron Avatar answered Oct 14 '22 08:10

Aaron