User Defined Type (UDT) behavior in Cassandra
Asked Answered
M

1

1

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

Medorra answered 15/12, 2015 at 21:55 Comment(0)
P
4

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.

Particular answered 15/12, 2015 at 22:42 Comment(2)
Thats what I assumed. How about the int and boolean types? Are int defaulted to 0 or something else?Medorra
Do you mean ints and booleans within a UDT? Those are also null. Cassandra don't default any types to a non-null value (anywhere).Particular

© 2022 - 2024 — McMap. All rights reserved.