Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-19637

LWT conditions behavior on collections is inconsistent

    XMLWordPrintableJSON

Details

    Description

      LWT conditions behaviour on collections is inconsistent in several ways around null values:

      1)Conditions comparing a collection column with a null value to a non-null have a different behaviour for frozen and non-frozen collection.

      UPDATE myTable SET l = ? WHERE k = 0 IF l < [1, 2]

      If l is null the previous query will return [false, null] for a frozen collection and [true] for a non-frozen collection.

      2) Conditions on non-frozen collection treat empty differently from null

      Due to the way multi-cell collections are implemented, it is not possible to differentiate between null and empty collections like it is feasible for single cell (frozen) collections. Therefore an empty multi-cell collection will always be treated as null.
      Unfortunately, the way LWT conditions handle that is not consistent with that.

      For example for colA list<int> non null:

      .. IF colA >= null

      will throw an invalid request error whereas

      ..IF colA >= []

      will returns true.
      Moreover, if we insert an empty list through:

      INSERT INTO mytable (pk, colA) VALUES (1, []);

      and use

      DELETE FROM mytable WHERE pk=1 IF colA = []

      the returned results will be

      {false, null}

      . Which can be quite confusing.

      The way to fix that behaviour to make it consistent with other operations is to consider empty multi-cell collection input as null and reject the null input for non = and != operators.

      Attachments

        Issue Links

          Activity

            People

              blerer Benjamin Lerer
              blerer Benjamin Lerer
              Benjamin Lerer
              Ekaterina Dimitrova
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3h 10m
                  3h 10m