Cassandra:将新列添加到表中 [英] Cassandra: Adding new column to the table
问题描述
您好,我刚刚在表my_table中添加了新列Business_sys:
Hi I just added a new column Business_sys to my table my_table:
ALTER TABLE my_table ALTER business_sys TYPE set<text>;
但是我还是删除了该列名,因为我想更改列的类型:
But again I just droped this column name because I wanted to change the type of column:
ALTER TABLE my_table DROP business_sys;
再次尝试添加具有不同类型的相同colmn名称时,出现错误消息
Again when I tried to add the same colmn name with different type am getting error message
"Cannnot add a collection with the name business_sys because the collection with the same name and different type has already been used in past"
我只是试图执行此命令以添加具有不同类型的新列-
I just tried to execute this command to add a new column with different type-
ALTER TABLE my_table ADD business_sys list<text>;
我做错了什么?我是Cassandra的新手。
What did I do wrong? I am pretty new to Cassandra. Any suggestions?
推荐答案
您遇到了 CASSANDRA-6276 。问题是,当您在Cassandra中删除一列时,该列中的数据不仅会消失,而且Cassandra可能会尝试使用其新的比较器类型读取该数据。
You're running into CASSANDRA-6276. The problem is when you drop a column in Cassandra that the data in that column doesn't just disappear, and Cassandra may attempt to read that data with its new comparator type.
从链接的JIRA故障单中:
From the linked JIRA ticket:
不幸的是,我们不允许从比较器中删除组件,包括从ColumnToCollectionType中删除单个集合列。
如果我们允许的话,并且拥有该类型的预先存在的数据,C *根本不知道如何比较这些数据。
Unfortunately, we can't allow dropping a component from the comparator, including dropping individual collection columns from ColumnToCollectionType. If we do allow that, and have pre-existing data of that type, C* simply wouldn't know how to compare those...
。 ..即使我们这样做了,并且允许[用户]创建一个具有相同名称的不同集合,我们也会遇到一个不同的问题:新集合的比较器将用于比较潜在的不兼容类型。
...even if we did, and allowed [users] to create a different collection with the same name, we'd hit a different issue: the new collection's comparator would be used to compare potentially incompatible types.
JIRA建议在Cassandra 3.x中这可能不是问题,但我只是在3.0.3中尝试过,但由于相同的错误而失败。 / p>
The JIRA suggests that this may not be an issue in Cassandra 3.x, but I just tried it in 3.0.3 and it fails with the same error.
我做错了什么?我是Cassandra的新手。有任何建议吗?
What did I do wrong? I am pretty new to Cassandra. Any suggestions?
不幸的是,解决这个问题的唯一方法是为新列表使用不同的名称。
Unfortunately, the only way around this one is to use a different name for your new list.
这篇关于Cassandra:将新列添加到表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!