cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin Lerer (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-11556) PER PARTITION LIMIT does not work properly for multi-partition query with ORDER BY
Date Wed, 13 Apr 2016 07:42:25 GMT

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

Benjamin Lerer commented on CASSANDRA-11556:
--------------------------------------------

Even if the {{LIMIT}} clause now works like for {{SQL}} a lot of users are still confused
by it (it might be because it was implemented wrongly before 2.2).
If you have a query like {{SELECT count((*)) FROM myTable PER PARTITION LIMIT 2}} it is easy
to be confused about what the result should be as it depends on when the limit will be applied
(before or after the aggregation). My guess is that some people will believe that the limit
is applied before the aggregation and that they will open some tickets to complain about it,
when they will discover it is not. It is why in the case of {{PER PARTITION LIMIT}}, I will
prefer to throw an error. Like that users do not get wrong expectations.

3 nits regarding the patch:
* It is better to not use {{assertRowsIgnoringOrder}} for testing ordering as it can hide
some ordering problem.
* Could you also add a test for {{SELECT * FROM %s WHERE a IN (2, 3) ORDER BY b DESC PER PARTITION
LIMIT ? LIMIT ?}}?
* the {{PER PARTITION LIMIT}} tests should probably be move to {{SelectLimitTest}} 

> PER PARTITION LIMIT does not work properly for multi-partition query with ORDER BY
> ----------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-11556
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11556
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Benjamin Lerer
>            Assignee: Alex Petrov
>             Fix For: 3.6
>
>
> Multi-partition queries with {{PER PARTITION LIMIT}} with {{ORDER BY}} do not respect
the {{PER PARTITION LIMIT}}.
> The problem can be reproduced with the following unit test:
> {code}
>     @Test
>     public void testPerPartitionLimitWithMultiPartitionQueryAndOrderBy() throws Throwable
>     {
>         createTable("CREATE TABLE %s (a int, b int, c int, PRIMARY KEY (a, b))");
>         for (int i = 0; i < 5; i++)
>         {
>             for (int j = 0; j < 5; j++)
>             {
>                 execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", i, j, j);
>             }
>         }
>         assertRows(execute("SELECT * FROM %s WHERE a IN (2, 3) ORDER BY b DESC PER PARTITION
LIMIT ?", 2),
>                                 row(2, 4, 4),
>                                 row(3, 4, 4),
>                                 row(2, 3, 3),
>                                 row(3, 3, 3));
>     }
> {code} 



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

Mime
View raw message