[ 
https://issues.apache.org/jira/browse/CASSANDRA-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14602820#comment-14602820
 ] 

Sam Tunnicliffe commented on CASSANDRA-9636:
--------------------------------------------

In both cases mentioned in the comments, the issue is that the Selection 
contains a result column which doesn't map to any underlying column (as both 
use the no-arg {{now()}} function). This was overlooked in the unit tests, but 
the unit testing wasn't quite rigorous enough anyway as it only verified the 
mappings collected for a given query matched expectations. It needs to go 
further and actually execute the query to ensure that the resultset can be 
properly constructed from the mappings. I've made the necessary changes to the 
tests & pushed a fix for the no-arg function case 
([2.0|https://github.com/beobal/cassandra/tree/9636-2.0], 
[2.1|https://github.com/beobal/cassandra/tree/9636-2.1]). I should note that 
this particular problem doesn't affect 2.2.

Regarding the original problem regarding duplicates in the selection, my 
characterisation of the pre-9532 behaviour was slightly off, so for the sake of 
clarity:

||Branch||pre-9532 behaviour||post-9532 behaviour||
|2.0|duplicates are included in results|AssertionError & error response|
|2.1|duplicates are collated|AssertionError & error response|
|2.2|AssertionError & error response|duplicates are collated|
 
The branches I've linked also revert 2.0 & 2.1 to their original behaviours.

> Duplicate columns in selection causes AssertionError
> ----------------------------------------------------
>
>                 Key: CASSANDRA-9636
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-9636
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Sam Tunnicliffe
>            Assignee: Sam Tunnicliffe
>             Fix For: 2.1.x, 2.0.x, 2.2.0 rc2
>
>
> Prior to CASSANDRA-9532, unaliased duplicate fields in a selection would be 
> silently ignored. Now, they trigger a server side exception and an unfriendly 
> error response, which we should clean up. Duplicate columns *with* aliases 
> are not affected.
> {code}
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 
> 'replication_factor': 1};
> CREATE TABLE ks.t1 (k int PRIMARY KEY, v int);
> INSERT INTO ks.t2 (k, v) VALUES (0, 0);
> SELECT k, v FROM ks.t2;
> SELECT k, v, v AS other_v FROM ks.t2;
> SELECT k, v, v FROM ks.t2;
> {code}
> The final statement results in this error response & server side stacktrace:
> {code}
> ServerError: <ErrorMessage code=0000 [Server error] 
> message="java.lang.AssertionError">
> ERROR 13:01:30 Unexpected exception during request; channel = [id: 
> 0x44d22e61, /127.0.0.1:39463 => /127.0.0.1:9042]
> java.lang.AssertionError: null
>         at org.apache.cassandra.cql3.ResultSet.addRow(ResultSet.java:63) 
> ~[main/:na]
>         at 
> org.apache.cassandra.cql3.statements.Selection$ResultSetBuilder.build(Selection.java:355)
>  ~[main/:na]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement.process(SelectStatement.java:1226)
>  ~[main/:na]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement.processResults(SelectStatement.java:299)
>  ~[main/:na]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:238)
>  ~[main/:na]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:67)
>  ~[main/:na]
>         at 
> org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:238)
>  ~[main/:na]
>         at 
> org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:260) 
> ~[main/:na]
>         at 
> org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:119)
>  ~[main/:na]
>         at 
> org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:439)
>  [main/:na]
>         at 
> org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:335)
>  [main/:na]
>         at 
> io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
>  [netty-all-4.0.23.Final.jar:4.0.23.Final]
>         at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
>  [netty-all-4.0.23.Final.jar:4.0.23.Final]
>         at 
> io.netty.channel.AbstractChannelHandlerContext.access$700(AbstractChannelHandlerContext.java:32)
>  [netty-all-4.0.23.Final.jar:4.0.23.Final]
>         at 
> io.netty.channel.AbstractChannelHandlerContext$8.run(AbstractChannelHandlerContext.java:324)
>  [netty-all-4.0.23.Final.jar:4.0.23.Final]
>         at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
> [na:1.8.0_45]
>         at 
> org.apache.cassandra.concurrent.AbstractTracingAwareExecutorService$FutureTask.run(AbstractTracingAwareExecutorService.java:164)
>  [main/:na]
>         at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:105) 
> [main/:na]
>         at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
> {code}
> This issue also presents on the head of the 2.2 branch and on 2.0.16. 
> However, the prior behaviour is different on both of those branches.
> In the 2.0 line prior to CASSANDRA-9532, duplicate columns would actually be 
> included in the results, as opposed to being silently dropped as per 2.1.x
> In 2.2, the assertion error seen above precedes CASSANDRA-9532 and is also 
> triggered for both aliased and unaliased duplicate columns.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to