在 Cassandra cqlsh 中插入数据时不匹配的列 names/values

Unmatched column names/values when inserting data in Cassandra 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 当这是我当前的机场 columnfamily 模型时:

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';

但是我看不到插入的问题!谁能帮我找出我哪里出错了?

当插入冻结的 udt 时,您不必为所有行(甚至是冻结的 udt 内的行)指定插入,因此为了修复查询,我必须删除所有行 elevation 列并添加 country.

好的,所以在将您的 xy 列调整为 doubles:

后,我确实设法完成了这项工作
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:Whosebug> 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(如您所述)时,您指定了每种类型的列。