在Cassandra cqlsh中插入数据时,列名称/值不匹配

时间:2018-02-13 14:36:29

标签: cassandra nosql cql cql3 cqlsh

所以我使用当前查询将数据插入我的列族:

INSERT INTO airports (apid, name, iata, icao, x, y, elevation, code, name, oa_code, dst, cid, name, timezone, tz_id) VALUES (12012,'Ararat Airport','ARY','YARA','142.98899841308594','-37.30939865112305',1008,{ code: 'AS', name: 'Australia', oa_code: 'AU', dst: 'U',city: { cid: 1, name: '', timezone: '', tz_id: ''}});

现在,我收到错误:Unmatched column names/values这是我目前的机场列家庭模型:

CREATE TYPE movielens.cityudt (
    cid varint,
    name text,
    timezone varint,
    tz_id text
);

CREATE TYPE movielens.countryudt (
    code text,
    name text,
    oa_code text,
    dst text,
    city frozen<cityudt>
);

CREATE TABLE movielens.airports (
    apid varint PRIMARY KEY,
    country frozen<countryudt>,
    elevation varint,
    iata text,
    icao text,
    name text,
    x varint,
    y varint
) WITH bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    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 = '99PERCENTILE';

但我看不到插入的问题!有人能帮我弄清楚我哪里出错吗?

2 个答案:

答案 0 :(得分:2)

好的,所以在将xy列调整为double后,我确实设法完成了这项工作:

INSERT INTO airports (apid, name, iata, icao, x, y, elevation, country)
VALUES (12012,'Ararat Airport','ARY','YARA',142.98899841308594,-37.30939865112305,
        1008,{ code: 'AS', name: 'Australia', oa_code: 'AU', dst: 'U', 
            city:{ cid: 1, name: '', timezone: 0, tz_id: ''}});

cassdba@cqlsh:stackoverflow> SELECT * FROM airports WHERE apid=12012;

 apid  | country                                                                                                    | elevation | iata | icao | name           | x       | y
-------+------------------------------------------------------------------------------------------------------------+-----------+------+------+----------------+---------+----------
 12012 | {code: 'AS', name: 'Australia', oa_code: 'AU', dst: 'U', city: {cid: 1, name: '', timezone: 0, tz_id: ''}} |      1008 |  ARY | YARA | Ararat Airport | 142.989 | -37.3094

(1 rows)

请记住,VARINT不会使用单引号(例如timezone)。

此外,当您只需在列列表中指定country时(如您所述),您指定了每个类型的列。

答案 1 :(得分:0)

当插入到冻结的udt中时,您不必为所有行指定插入(即使是冻结的udt中的那些行),因此为了修复查询,我必须删除elevation以外的所有行。列并添加country