CASSANDRA Skills 2 — Questions and Answers
Question 1: Which CQL command exports a table's data to a CSV file on the local filesystem?
- EXPORT TABLE
- COPY TO (Correct answer)
- SELECT INTO OUTFILE
- DUMP TABLE
Correct answer: COPY TO
COPY TO writes rows from a Cassandra table into a delimited file, most commonly CSV.
Question 2: What is the purpose of the `nodetool repair` command in Cassandra?
- Compacts SSTables to reclaim disk space
- Synchronizes replicas to fix inconsistencies (Correct answer)
- Removes tombstones from the commit log
- Rebuilds secondary indexes on all nodes
Correct answer: Synchronizes replicas to fix inconsistencies
`nodetool repair` runs anti-entropy repair, comparing and reconciling data across replicas to ensure consistency.
Question 3: When designing a Cassandra data model, what drives the primary choice of partition key?
- Minimizing total row count
- Supporting the application's most common query patterns (Correct answer)
- Ensuring alphabetical ordering of results
- Maximizing column family width
Correct answer: Supporting the application's most common query patterns
The partition key determines data distribution and must be chosen based on how the application will query the data.
Question 4: Which Cassandra feature allows you to set an automatic expiration time on individual rows or columns?
- Lightweight transactions (LWT)
- TTL (Time To Live) (Correct answer)
- Compaction strategy
- Materialized views
Correct answer: TTL (Time To Live)
TTL sets a time-to-live in seconds on data, after which Cassandra marks it with a tombstone and eventually removes it.
Question 5: What does the `ALLOW FILTERING` clause do in a CQL SELECT statement?
- Enables server-side filtering that may require a full partition scan (Correct answer)
- Permits queries without a WHERE clause on primary keys
- Disables client-side filtering for performance
- Forces use of a secondary index
Correct answer: Enables server-side filtering that may require a full partition scan
ALLOW FILTERING permits Cassandra to filter data server-side, potentially scanning many partitions, which can be very slow at scale.
Question 6: How does Cassandra handle a write when one of the replica nodes is temporarily unavailable?
- The write is rejected and an error is returned
- The write is stored as a hinted handoff on a coordinator node (Correct answer)
- The write is buffered client-side until the node recovers
- The write is applied only to the available replicas permanently
Correct answer: The write is stored as a hinted handoff on a coordinator node
Hinted handoff stores the missed write on the coordinator, which replays it to the recovered node once it comes back online.
Question 7: Which compaction strategy is best suited for time-series data where old data is rarely updated?
- SizeTieredCompactionStrategy (STCS)
- LeveledCompactionStrategy (LCS)
- TimeWindowCompactionStrategy (TWCS) (Correct answer)
- UnifiedCompactionStrategy (UCS)
Correct answer: TimeWindowCompactionStrategy (TWCS)
TWCS groups SSTables into time windows and compacts within each window, minimizing read amplification for time-series workloads.
Which CQL command exports a table's data to a CSV file on the local filesystem?