arnulf.hanauer_193730 avatar image
arnulf.hanauer_193730 asked Erick Ramirez edited

Cannot re-add previously dropped column

After running an ALTER TABLE DROP <column_name>, I am unable to re-add the same column_name at a later date.

Are column_names not reusable ever?

Can you please confirm the process/conditions required to re-use a column name with or without a TYPE change as well.

I have run nodetool upgradesstables <ks> as well as nodetool compact <ks> <tbl> which is supposed to remove the tombstone information which I was under the impression is holding up the re-usability or do I need to force gc_grace_seconds before the compaction.

Full error message from CQL is

InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot re-add previously dropped column ...
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered Erick Ramirez edited

It is not possible to add a column with the same name as a column that was previously dropped from a table. There is no condition where this is possible, even when no data has been inserted into the table yet.


The Cassandra storage engine was completely refactored in 3.0 (CASSANDRA-8099).

As part of the refactoring, the SerializationHeader class only retrieves the column names from the metadata (see SerializationHeader.toHeader() method in C* 3.0.21) and ignores the kinds of columns they are, i.e. regular or static. If a column's kind is changed via ALTER TABLE ... DROP then eventually ADD, the header could be interpreted incorrectly and may lead to CorruptSSTableException or data corruption (CASSANDRA-14843).


The proposed solution to the problem described above is to store additional metadata about the dropped columns but it is only planned to be implemented in a future major version.

The workaround in C* 3.x is to simply prevent columns from being added back to a table after it has been dropped (CASSANDRA-14948). This improvement completely prevents DBAs from re-using column names in a table.


If you really must use the same name, I would recommend adding a suffix like "v2" so the new column name is of the form columnname_v2. Cheers!

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.