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

java internal exception on attempt to UPDATE a row using CONTAINS operator

    XMLWordPrintableJSON

Details

    Description

      kostja@atlas ~ % cqlsh -ucassandra -pcassandra
      Connected to My Cluster at 127.0.0.1:9042.
      [cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]
      Use HELP for help.
      cassandra@cqlsh> CREATE KEYSPACE t1 WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 1};
      cassandra@cqlsh> use t1;
      cassandra@cqlsh:t1> create table t (a int, b frozen<map<int, int>>, c int, primary key (a, b));
      cassandra@cqlsh:t1> insert into t (a, b, c) values (1, {1:1, 2:2}, 3);
      cassandra@cqlsh:t1> update t set c=3 where a=1 and b contains 1;
      ServerError: java.lang.UnsupportedOperationException

       

      Server log file:

      ```

      ERROR [Native-Transport-Requests-1] 2019-08-07 17:02:59,283 QueryMessage.java:129 - Unexpected error during query
      java.lang.UnsupportedOperationException: null
      at org.apache.cassandra.cql3.restrictions.SingleColumnRestriction$ContainsRestriction.appendTo(SingleColumnRestriction.java:454) ~[a
      pache-cassandra-3.11.4.jar:3.11.4]
      at org.apache.cassandra.cql3.restrictions.ClusteringColumnRestrictions.valuesAsClustering(ClusteringColumnRestrictions.java:109) ~[a
      pache-cassandra-3.11.4.jar:3.11.4]
      at org.apache.cassandra.cql3.restrictions.StatementRestrictions.getClusteringColumns(StatementRestrictions.java:770) ~[apache-cassan
      dra-3.11.4.jar:3.11.4]
      at org.apache.cassandra.cql3.statements.ModificationStatement.createClustering(ModificationStatement.java:312) ~[apache-cassandra-3.
      11.4.jar:3.11.4]
      at org.apache.cassandra.cql3.statements.ModificationStatement.addUpdates(ModificationStatement.java:677) ~[apache-cassandra-3.11.4.j
      ar:3.11.4]
      at org.apache.cassandra.cql3.statements.ModificationStatement.getMutations(ModificationStatement.java:635) ~[apache-cassandra-3.11.4
      .jar:3.11.4]
      at org.apache.cassandra.cql3.statements.ModificationStatement.executeWithoutCondition(ModificationStatement.java:437) ~[apache-cassa
      ndra-3.11.4.jar:3.11.4]
      at org.apache.cassandra.cql3.statements.ModificationStatement.execute(ModificationStatement.java:425) ~[apache-cassandra-3.11.4.jar:
      3.11.4]
      at org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:225) ~[apache-cassandra-3.11.4.jar:3.11.4]
      at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:256) ~[apache-cassandra-3.11.4.jar:3.11.4]
      at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:241) ~[apache-cassandra-3.11.4.jar:3.11.4]
      at org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:116) ~[apache-cassandra-3.11.4.jar:3.11.4]
      at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:566) [apache-cassandra-3.11.4.jar:3.11.4]
      at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:410) [apache-cassandra-3.11.4.jar:3.11.4]
      at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [netty-all-4.0.44.Final.jar:4.0.44
      ...

       ```
      Additional information for newcomers:

      CONTAINS and CONTAINS KEY restrictions are not supported for UPDATE or DELETE operations but they should be properly rejected with a proper error message.
      To fix that problem a new check should be added in the StatementRestrictions constructor to thrown an InvalidRequestException if the relation operator is a CONTAINS or CONTAINS_KEY and the StatementType an UPDATE or a DELETION.
      Some unit tests should be added to UpdateTest an DeleteTest to test the behavior.

      Attachments

        Activity

          People

            masokol Maciej Sokol
            Osipov Konstantin
            Maciej Sokol
            Andres de la Peña, Benjamin Lerer
            Votes:
            0 Vote for this issue
            Watchers:
            4 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 - 1h 20m
                1h 20m