Every time I try to create a new table in cassandra with a new TableDef I end up with a clustering order of ascending and I'm trying to get descending.
我正在使用Cassandra 2.1.10,Spark 1.5.1和Datastax Spark Cassandra Connector 1.5.0-M2 .
我正在创建一个新的 TableDef
val table = TableDef("so", "example",
Seq(ColumnDef("parkey", PartitionKeyColumn, TextType)),
Seq(ColumnDef("ts", ClusteringColumn(0), TimestampType)),
Seq(ColumnDef("name", RegularColumn, TextType)))
rdd.saveAsCassandraTableEx(table, SomeColumns("key", "time", "name"))
我期待在Cassandra看到的是
CREATE TABLE so.example (
parkey text,
ts timestamp,
name text,
PRIMARY KEY ((parkey), ts)
) WITH CLUSTERING ORDER BY (ts DESC);
我最终得到的是
CREATE TABLE so.example (
parkey text,
ts timestamp,
name text,
PRIMARY KEY ((parkey), ts)
) WITH CLUSTERING ORDER BY (ts ASC);
如何强制它将聚类顺序设置为降序?
1 回答
我无法找到这样做的直接方法 . 此外,您可能还需要指定许多其他选项 . 我最终扩展
ColumnDef
和TableDef
并覆盖TableDef
中的cql
方法 . 我想出的解决方案的一个例子如下 . 如果某人有更好的方式,或者这种方式得到本地支持,我很乐意改变答案 .这允许我以这种方式创建新表: