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

selecting field from empty UDT cell using dot notation triggers exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 2.1.0
    • None
    • Low

    Description

      Hopefully the title explains the issue.

      Basically if a row has a user type which is undefined, using the "dot notation" syntax causes cqlsh to show a NPE, and an exception ends up in the log as well.

      I would expect the behavior here to execute the query and return null, since the user type itself is null, then it's fields are null as well (the downside here is there would be no way to distinguish between a null UDT and a null UDT field, without making an initial query to check if the UDT is non-null).

      Steps to repro:

      create keyspace test with replication = {'class':'SimpleStrategy', 'replication_factor':1};
      
      use test;
      
      CREATE TYPE t_item (subitem text);
      
      create table mytable (value1 text PRIMARY KEY, value2 text, item t_item);
      
      insert into mytable (value1, value2 ) values ('foo', 'bar');
      
      select item.subitem from mytable;
      <ErrorMessage code=0000 [Server error] message="java.lang.NullPointerException">
      

      Here's the exception logged:

      ERROR [SharedPool-Worker-1] 2014-08-01 15:49:00,514 ErrorMessage.java:218 - Unexpected exception during request
      java.lang.NullPointerException: null
              at org.apache.cassandra.db.marshal.TupleType.split(TupleType.java:146) ~[main/:na]
              at org.apache.cassandra.cql3.statements.Selection$FieldSelector.compute(Selection.java:469) ~[main/:na]
              at org.apache.cassandra.cql3.statements.Selection$SelectionWithFunctions.handleRow(Selection.java:537) ~[main/:na]
              at org.apache.cassandra.cql3.statements.Selection$ResultSetBuilder.build(Selection.java:333) ~[main/:na]
              at org.apache.cassandra.cql3.statements.SelectStatement.process(SelectStatement.java:1149) ~[main/:na]
              at org.apache.cassandra.cql3.statements.SelectStatement.processResults(SelectStatement.java:283) ~[main/:na]
              at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:225) ~[main/:na]
              at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:60) ~[main/:na]
              at org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:187) ~[main/:na]
              at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:206) ~[main/:na]
              at org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:118) ~[main/:na]
              at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:421) [main/:na]
              at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:318) [main/:na]
              at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:103) [netty-all-4.0.20.Final.jar:4.0.20.Final]
              at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:332) [netty-all-4.0.20.Final.jar:4.0.20.Final]
              at io.netty.channel.AbstractChannelHandlerContext.access$700(AbstractChannelHandlerContext.java:31) [netty-all-4.0.20.Final.jar:4.0.20.Final]
              at io.netty.channel.AbstractChannelHandlerContext$8.run(AbstractChannelHandlerContext.java:323) [netty-all-4.0.20.Final.jar:4.0.20.Final]
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_65]
              at org.apache.cassandra.concurrent.AbstractTracingAwareExecutorService$FutureTask.run(AbstractTracingAwareExecutorService.java:163) [main/:na]
              at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:103) [main/:na]
              at java.lang.Thread.run(Thread.java:745) [na:1.7.0_65]
      

      Attachments

        1. CASSANDRA-2.1.0-7670.patch
          1 kB
          Mikhail Stepura

        Activity

          People

            mishail Mikhail Stepura
            rhatch Russ Hatch
            Mikhail Stepura
            Sylvain Lebresne
            Russ Hatch Russ Hatch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: