Cassandra创建表不会保持列顺序 [英] Cassandra create table won't keep column order
问题描述
我正在Cassandra中创建一个列族,并且希望列顺序与我在create子句中指定的列顺序匹配。
I am creating a column family in Cassandra and I expect the column order to match the one I am specifying in the create clause.
此
CREATE TABLE cf.mycf (
timestamp timestamp,
id text,
score int,
type text,
publisher_id text,
embed_url text,
PRIMARY KEY (timestamp, id, score)
) WITH bloom_filter_fp_chance = 0.01
AND comment = ''
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE'
AND caching = {
'keys' : 'ALL',
'rows_per_partition' : 'NONE'
}
AND compression = {
'chunk_length_kb' : 64,
'crc_check_chance' : 1.0,
'sstable_compression' : 'LZ4Compressor'
}
AND compaction = {
'base_time_seconds' : 60,
'class' : 'DateTieredCompactionStrategy',
'enabled' : true,
'max_sstable_age_days' : 365,
'max_threshold' : 32,
'min_threshold' : 4,
'timestamp_resolution' : 'MICROSECONDS',
'tombstone_compaction_interval' : 86400,
'tombstone_threshold' : 0.2,
'unchecked_tombstone_compaction' : false
};
应创建一个表,如:
timestamp,id,score ,类型,id,embed_url
相反,我得到的是:
timestamp timestamp,
id text,
score int,
embed_url text,
publisher_id text,
type text,
我已经用相同的方式创建了很多表格,但是这从未发生过,因此不胜感激。
I've created quite a few tables in the same way and this never happened so any help would be appreciated.
我将 id
和 score
作为键表明这些保持各自的位置。而我正在寻找的实际方案只是将时间戳记为主键。
I put the id
and score
as keys to show that these keep their respective position. while the actual scheme I am looking for is only the timestamp to be the primary key.
推荐答案
在cassandra中似乎没有字段排序之类的东西。
Looks like there is no such thing as fields order in cassandra.
The others columns are displayed in alphabetical order by Cassandra.
http://docs.datastax.com/en/cql/3.1/cql/ddl/ddl_compound_keys_c.html
这篇关于Cassandra创建表不会保持列顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!