You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Jeff Jirsa (JIRA)" <ji...@apache.org> on 2018/03/03 03:17:00 UTC

[jira] [Updated] (CASSANDRA-14286) IndexOutOfBoundsException with SELECT JSON using IN and ORDER BY

     [ https://issues.apache.org/jira/browse/CASSANDRA-14286?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Jirsa updated CASSANDRA-14286:
-----------------------------------
    Component/s: CQL

> IndexOutOfBoundsException with SELECT JSON using IN and ORDER BY
> ----------------------------------------------------------------
>
>                 Key: CASSANDRA-14286
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-14286
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>         Environment: Kubernetes cluster using cassandra:3.11.1 Docker image.
>            Reporter: Szymon Acedański
>            Priority: Major
>             Fix For: 3.11.x
>
>         Attachments: orderbug-traceback.txt
>
>
> When running the following code:
> {code}
> public class CassandraJsonOrderingBug {
>     public static void main(String[] args) {
>         Session session = CassandraFactory.getSession();
>         session.execute("CREATE TABLE thebug ( PRIMARY KEY (a, b), a INT, b INT)");
>         try {
>             session.execute("INSERT INTO thebug (a, b) VALUES (20, 30)");
>             session.execute("INSERT INTO thebug (a, b) VALUES (100, 200)");
>             Statement statement = new SimpleStatement("SELECT JSON a, b FROM thebug WHERE a IN (20, 100) ORDER BY b");
>             statement.setFetchSize(Integer.MAX_VALUE);
>             for (Row w: session.execute(statement)) {
>                 System.out.println(w.toString());
>             }
>         } finally {
>             session.execute("DROP TABLE thebug");
>         }
>     }
> }
> {code}
> The following exception is thrown server-side:
> {noformat}
> java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
> 	at java.util.Collections$SingletonList.get(Collections.java:4815) ~[na:1.8.0_151]
> 	at org.apache.cassandra.cql3.statements.SelectStatement$SingleColumnComparator.compare(SelectStatement.java:1297) ~[apache-cassandra-3.11.1.jar:3.11.1]
> 	at org.apache.cassandra.cql3.statements.SelectStatement$SingleColumnComparator.compare(SelectStatement.java:1284) ~[apache-cassandra-3.11.1.jar:3.11.1]
> 	at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) ~[na:1.8.0_151]
> 	at java.util.TimSort.sort(TimSort.java:220) ~[na:1.8.0_151]
> 	at java.util.Arrays.sort(Arrays.java:1512) ~[na:1.8.0_151]
> 	at java.util.ArrayList.sort(ArrayList.java:1460) ~[na:1.8.0_151]
> 	at java.util.Collections.sort(Collections.java:175) ~[na:1.8.0_151]
> {noformat}
> (full traceback attached)
> The accessed index is the index of the sorted column in the SELECT JSON fields list.
> Similarly, if the select clause is changed to
> SELECT JSON b, a FROM thebug WHERE a IN (20, 100) ORDER BY b
> then the query finishes, but the output is sorted incorrectly (by textual JSON representation):
> {noformat}
> Row[{"b": 200, "a": 100}]
> Row[{"b": 30, "a": 20}]
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org