Apache Cassandra Compatibility in YCQL

    By default, inserts overwrite data on primary key collisions. So INSERTs do an upsert. This an intended CQL feature. In order to insert data only if the primary key is not already present, add a clause “IF NOT EXISTS” to the INSERT statement. This will cause the INSERT fail if the row exists.

    Here is an example from CQL:

    Unlike Apache Cassandra, Yugabyte COUNTER type is almost the same as INTEGER types. There is no need of lightweight transactions requiring 4 round trips to perform increments in Yugabyte - these are efficiently performed with just one round trip.

    In Apache Cassandra, the highest timestamp provided always wins. Example:

    1. > INSERT INTO table (c1, c2, c3) VALUES (1, 2, 3) USING TIMESTAMP 1607681258727447;
    2. > SELECT * FROM table;
    1. ----+----+----
    2. 1 | 2 | 3

    INSERT at the current timestamp does not overwrite previous value which was written at a highertimestamp.

    1. c1 | c2 | c3
    2. 1 | 2 | 3

    On the other hand in Yugabyte, for efficiency purposes INSERTs and UPDATEs without the USINGTIMESTAMP clause always overwrite the older values. On the other hand if we have the USINGTIMESTAMP clause, then appropriate timestamp ordering is performed. Example:

    1. > INSERT INTO table (c1, c2, c3) VALUES (1, 2, 3) USING TIMESTAMP 1000;
    1. > INSERT INTO table (c1, c2, c3) VALUES (1, 2, 4) USING TIMESTAMP 1607681258727447;
    1. c1 | c2 | c3
    2. ----+----+----
    3. 1 | 2 | 4

    INSERT without ‘USING TIMESTAMP’ will always overwrite.

    1. c1 | c2 | c3
    2. 1 | 2 | 5