【问题标题】:insert into column family with case sensitive column name插入具有区分大小写的列名的列族
【发布时间】:2013-12-18 09:46:04
【问题描述】:

我正在使用以下 Cassandra/CQL 版本:

[cqlsh 4.0.1 |卡桑德拉 2.0.1 | CQL 规范 3.1.1 | Thrift 协议 19.37.0]

我正在尝试将数据插入到具有区分大小写的列名的预先存在的 CF 中。尝试插入数据时遇到“未知标识符”错误。

以下是列族的描述方式:

CREATE TABLE "Sample_List_CS" (
  key text,
  column1 text,
  "fName" text,
  "ipSubnet" text,
  "ipSubnetMask" text,
  value text,
  PRIMARY KEY (key, column1)
) WITH COMPACT STORAGE AND
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=0 AND
  index_interval=128 AND
  read_repair_chance=0.000000 AND
  replicate_on_write='false' AND
  populate_io_cache_on_flush='false' AND
  default_time_to_live=0 AND
  speculative_retry='NONE' AND
  memtable_flush_period_in_ms=0 AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'LZ4Compressor'};

CREATE INDEX ipSubnet ON "Sample_List_CS" ("ipSubnet");

插入语句导致错误:

cqlsh:Sample_KS> INSERT INTO "Sample_List_CS" (key,column1,"fName") VALUES    ('123','1','myValue');
Bad Request: Unknown identifier fName

cqlsh:Sample_KS> INSERT INTO "Sample_List_CS" (key,column1,"ipSubnet") VALUES    ('123','1','255');
Bad Request: Unknown identifier ipSubnet

知道我做错了什么吗?

【问题讨论】:

  • 我用[cqlsh 4.1.0 | Cassandra 2.0.2 | CQL spec 3.1.1 | Thrift protocol 19.38.0] 运行了这些命令,它们对我有用。 (在CREATE TABLE 上没有WITH COMPACT STORAGE
  • 感谢您的验证,我在没有紧凑型存储的情况下尝试了同样的方法,它也有效。

标签: cassandra cassandra-2.0


【解决方案1】:

据我了解,当使用WITH COMPACT STORAGE 时,一个表可能只有一列而不是主键。

引用the manual:

使用紧凑存储指令可防止您添加超过 一列不属于 PRIMARY KEY。

对您而言,这意味着您的表格中只能包含以下 4 列之一:

  • “fName”
  • “ipSubnet”
  • “ipSubnetMask”
  • 价值

(或者,您可以将其中的 3 个添加到主键定义中。)

因此,其他三列导致Unknown identifier 错误是有道理的。

【讨论】:

  • 感谢您的指点。事实证明,预先存在的列族是使用 hector api 创建的,并且默认配置为“紧凑存储”。你的推理看起来是正确的,我创建了一个没有紧凑存储的新 CF,一切正常。
猜你喜欢
  • 1970-01-01
  • 2014-09-06
  • 2014-03-18
  • 1970-01-01
  • 2012-05-13
  • 1970-01-01
  • 2014-01-19
相关资源
最近更新 更多