Database / Apache Cassandra Intermediate and Advanced interview questions
What are User Defined Types (UDTs) in Cassandra?
User Defined Types let you group related fields into a single named, reusable structure, similar to a struct, instead of flattening everything into individual table columns.
CREATE TYPE address ( street text, city text, zip text ); CREATE TABLE customers ( customer_id uuid PRIMARY KEY, name text, home_address frozen<address> ); INSERT INTO customers (customer_id, name, home_address) VALUES (uuid(), 'Jane Doe', {street: '1 Main St', city: 'Austin', zip: '73301'});
- UDTs can be nested inside collections, such as a
list<frozen<address>>for multiple addresses. - When used inside a collection, a UDT (and the collection itself) traditionally had to be marked
frozen, meaning the whole value is serialized as one blob and must be replaced entirely, not partially updated. Newer Cassandra versions allow non-frozen UDTs at the top level of a column, permitting field-level updates. - UDTs improve readability and reduce column sprawl, but frozen UDTs can't have individual fields updated with a lightweight
UPDATE ... SET field = value— you must rewrite the entire value.
UDTs are best used for genuinely structured, cohesive data (like an address or a money amount with currency) rather than as a general substitute for proper table design.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
