Migrating from compact storage

Change a table that uses compact storage to a regular CQL table.

Before upgrading to a version of DataStax Enterprise that does not support COMPACT STORAGE, remove Thrift compatibility mode from the table. Migrate to the CQL-compatible format using the ALTER TABLE DROP COMPACT STORAGE option.

Migration changes the CQL table schema to expose any Thrift written data that was previously hidden from CQL according to the following rules:
  • COMPACT STORAGE table that has no clustering columns:
    • Two new columns column1 text and value blob are added. These columns contain any data written outside the CQL table schema to the Thrift table.
    • column1 becomes a clustering column.
    • All regular columns become static columns.
  • COMPACT STORAGE table with one or more clustering columns that has no regular columns:
    • Column named value with type empty is added.
  • Thrift-created SuperColumn table exposes a compact value map with an empty name.
  • Thrift-created Compact Tables column data types correspond to the Thrift definition.
Restriction: Removing Thrift compatibility from a table that also has a search index disables HTTP writes and deletes-by-ID on the search index.
Use the following syntax to change the table storage type:
ALTER TABLE keyspace_name.table_name
DROP COMPACT STORAGE;

Example

Simple partition key table

The following table has only a single primary key column:
CREATE TABLE cycling.cyclist_alt_stats (
    id UUID PRIMARY KEY,
    lastname text,
    birthday date,
    nationality text,
    weight float,
    w_units text,
    height float,
    first_race date,
    last_race date)
 WITH COMPACT STORAGE;
Migrate to a standard CQL table:
ALTER TABLE cycling.cyclist_alt_stats
DROP COMPACT STORAGE;
Show the updated table schema:
DESC TABLE cycling.cyclist_alt_stats ;
Two columns were added, column1 and value. column1 was added to the PRIMARY KEY as a clustering column. And all the regular columns are changed to static columns.
CREATE TABLE cycling.cyclist_alt_stats (
    id uuid,
    column1 text,
    birthday date static,
    first_race date static,
    height float static,
    last_race date static,
    lastname text static,
    nationality text static,
    value blob,
    w_units text static,
    weight float static,
    PRIMARY KEY (id, column1)
) WITH CLUSTERING ORDER BY (column1 ASC)