我有一个带有TEXT类型的空列的Cassandra表,它出现在DESCRIBE TABLE中但不出现在SELECT列FROM表,ALTER TABLE表DROP列或ALTER TABLE表RENAME列TO new_column中。 如何在不丢失任何数据的情况下删除此列?
这是一个3节点集群。 /var/log/cassandra/system.log,cassandra.log或debug.log中没有记录错误。
nodetool upgradedesstables和nodetool repair都没有报告任何错误。每个都在集群的所有3个节点上执行。
$ cqlsh 192.168.1.1 9042
Connected to my_laptop at 192.168.1.1:9042.
[cqlsh 5.0.1 | Cassandra 3.0.9 | CQL spec 3.4.0 | Native protocol v4]
CREATE TABLE proj.stuff (
my_id uuid PRIMARY KEY,
her_id uuid,
her_name text,
my_odd_column text,
status boolean
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = 'Stores Initiative Entity for MyProject'
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';
cqlsh:proj> ALTER TABLE stuff RENAME my_odd_column TO old_my_odd_column;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot
rename unknown column my_odd_column in keyspace stuff"
注意:错误消息中的键空间名称错误,它实际上是表名
cqlsh:proj> ALTER TABLE stuff DROP my_odd_column;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Column
my_odd_column was not found in table stuff"
cqlsh:proj> SELECT my_id, my_odd_column FROM stuff;
InvalidRequest: Error from server: code=2200 [Invalid query]
message="Undefined name my_odd_column in selection clause"