Comments - Cassandra Storage Engine Use Example

 
8 years, 1 month ago Paul Reichow

Apparently the syntax for creating namespaces in Cassandra changed since this article was written three years ago.

Some of the other responses here tell you how to use the old syntax using various options when starting cqlsh.

Here's the updated equivalent command, with Cassandra 3.7 | CQL spec 3.4.2:

CREATE KEYSPACE mariadbtest2 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}  AND durable_writes = true;
 
10 years, 6 months ago Jurj Alin

I have a cassandra with 100k columns and with compact storage, however i still cant make this work

create table stats (some_key varchar(255) primary key, dynamic_cols blob DYNAMIC_COLUMN_STORAGE=yes) engine=cassandra keyspace='ks1' column_family='cf1'`

i get

ERROR 1429 (HY000): Unable to connect to foreign data source: Column family cf1 not found in keyspace ks1

any idea what could this be ?

 
11 years, 3 months ago Robert Wagner

If you run:

cqlsh> USE mariadbtest2;
cqlsh:mariadbtest2> create columnfamily cf2 (pk varchar, data1 varchar, data2 bigint, PRIMARY KEY (pk ,data1));

and then try to connect a SQL table, you will get:

MariaDB [test2]> create table t2 (
  pk varchar(36) primary key,
  data1 varchar(60),
  data2 bigint
) engine=cassandra  thrift_host='IP_ADDRESS' keyspace='mariadbtest2' column_family='cf2';

ERROR 1429 (HY000): Unable to connect to foreign data source: Column family cf2 not found in keyspace mariadbtest2
 
8 years, 2 months ago Nick Ivanov

Because MariaDB uses deprecated thrift driver You have to add a WITH COMPACT STORAGE option to the create columnfamily query:

create columnfamily cf2 (pk varchar, data1 varchar, data2 bigint, PRIMARY KEY (pk ,data1)) WITH COMPACT STORAGE;
 
11 years, 3 months ago Robert Wagner

Connecting SQL table does not work as shown:

MariaDB [test2]> create table t1 (
  rowkey varchar(36) primary key,
  data1 varchar(60),
  data2 bigint
) engine=cassandra  thrift_host='10.60.1.47' keyspace='mariadbtest2' column_family='cf1';
ERROR 1928 (HY000): Internal error: 'PRIMARY KEY column must match Cassandra's name 'pk''

One should change the Primary Key to pk:

MariaDB [test2]> create table t1 (
  pk varchar(36) primary key,
  data1 varchar(60),
  data2 bigint
) engine=cassandra  thrift_host='10.60.1.47' keyspace='mariadbtest2' column_family='cf1';
Query OK, 0 rows affected (0.00 sec)
 
11 years, 3 months ago Robert Wagner

The above example does not work when running cqlsh with the -3 option.

cqlsh:> CREATE KEYSPACE mariadbtest2 WITH strategy_class = 'org.apache.cassandra.locator.SimpleStrategy' AND strategy_options:replication_factor='1';
Bad Request: line 1:117 mismatched input ':' expecting '='
Perhaps you meant to use CQL 2? Try using the -2 option when starting cqlsh.

One must run cqlsh with the -2 option:

[root@localhost bin]# ./cqlsh <IPADDRESS of Cassandra> 9160 -2
 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.