You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Benjamin Lerer (JIRA)" <ji...@apache.org> on 2015/11/02 17:13:27 UTC
[jira] [Comment Edited] (CASSANDRA-10271) ORDER BY should allow
skipping equality-restricted clustering columns
[ https://issues.apache.org/jira/browse/CASSANDRA-10271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14985453#comment-14985453 ]
Benjamin Lerer edited comment on CASSANDRA-10271 at 11/2/15 4:12 PM:
---------------------------------------------------------------------
[~bsnyder788] Sorry, I realized that my previous comment was not clear.
The following queries should be valid:
* {{SELECT * FROM %s WHERE a=? AND b=? AND c >= ? ORDER BY c ASC}} (if b and c are the clustering columns)
* {{SELECT * FROM %s WHERE a=? AND b=? AND c IN (?, ?) ORDER BY c ASC}} (if b and c are the clustering columns)
* {{SELECT * FROM %s WHERE a=? AND b=? AND (c , d) > (?, ?) ORDER BY c ASC, d ASC}} (if b, c and d are the clustering columns)
As the order is specified for the {{c}} and {{d}} columns we should allow them.
We should probably even allow queries like:
{{SELECT * FROM %s WHERE a=? AND b IN (?, ?) AND c = ? ORDER BY b ASC}}
[~thobbs] What do you think?
was (Author: blerer):
[~bsnyder788] Sorry, I realized that my previous comment was not clear.
The following queries should be valid:
* {{SELECT * FROM %s WHERE a=? AND b=? AND c >= ? ORDER BY c ASC}}
* {{SELECT * FROM %s WHERE a=? AND b=? AND c IN (?, ?) ORDER BY c ASC}}
* {{SELECT * FROM %s WHERE a=? AND b=? AND (c , d) > (?, ?) ORDER BY c ASC, d ASC}}
As the order is specified for the {{c}} and {{d}} columns we should allow them.
We should probably even allow queries like:
{{SELECT * FROM %s WHERE a=? AND b IN (?, ?) AND c = ? ORDER BY b ASC}}
[~thobbs] What do you think?
> ORDER BY should allow skipping equality-restricted clustering columns
> ---------------------------------------------------------------------
>
> Key: CASSANDRA-10271
> URL: https://issues.apache.org/jira/browse/CASSANDRA-10271
> Project: Cassandra
> Issue Type: Improvement
> Components: CQL
> Reporter: Tyler Hobbs
> Assignee: Brett Snyder
> Priority: Minor
> Fix For: 3.x, 2.2.x
>
> Attachments: cassandra-2.2-10271.txt
>
>
> Given a table like the following:
> {noformat}
> CREATE TABLE foo (a int, b int, c int, d int, PRIMARY KEY (a, b, c));
> {noformat}
> We should support a query like this:
> {noformat}
> SELECT * FROM foo WHERE a = 0 AND b = 0 ORDER BY c ASC;
> {noformat}
> Currently, this results in the following error:
> {noformat}
> [Invalid query] message="Order by currently only support the ordering of columns following their declared order in the PRIMARY KEY"
> {noformat}
> However, since {{b}} is restricted by an equality restriction, we shouldn't require it to be present in the {{ORDER BY}} clause.
> As a workaround, you can use this query instead:
> {noformat}
> SELECT * FROM foo WHERE a = 0 AND b = 0 ORDER BY b ASC, c ASC;
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)