Search code examples
cassandradatastaxdatastax-enterprisecql3datastax-java-driver

User Defined Type (UDT) behavior in Cassandra


if someone has some experience in using UDT (User Defined Types), I would like to understand how the backward compatibility would work.

Say I have the following UDT

CREATE TYPE addr (
  street1 text,
  zip text,
  state text
);

If I modify "addr" UDT to have a couple of more attributes (say for example zip_code2 int, and name text):

CREATE TYPE addr (
  street1 text,
  zip text,
  state text,
  zip_code2 int,
  name text
);

how does the older rows that does have these attributes work? Is it even compatible?

Thanks


Solution

  • The new UDT definition would be compatible with the old definition. User-defined types can have null values for fields, so if you alter the type definition, all existing values for that type will simply have null values for the added fields.