Updated Branches: refs/heads/trunk f8e52ea98 -> 811359db0
Re-allow order by on non-selected columns patch by slebresne; reviewed by jbellis for CASSANDRA-4645 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/811359db Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/811359db Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/811359db Branch: refs/heads/trunk Commit: 811359db0adeb3ac312708840379497ea950a0a4 Parents: f8e52ea Author: Sylvain Lebresne <[email protected]> Authored: Mon Nov 5 17:05:45 2012 +0100 Committer: Sylvain Lebresne <[email protected]> Committed: Mon Nov 5 17:05:45 2012 +0100 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cassandra/cql3/statements/SelectStatement.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/811359db/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 75416d5..89c046e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -50,6 +50,7 @@ * Fix short read protection for CQL3 (CASSANDRA-4882) * Add tracing support to the binary protocol (CASSANDRA-4699) * Don't allow prepared marker inside collections (CASSANDRA-4890) + * Re-allow order by on non-selected columns (CASSANDRA-4645) Merged from 1.1: * add get[Row|Key]CacheEntries to CacheServiceMBean (CASSANDRA-4859) * fix get_paged_slice to wrap to next row correctly (CASSANDRA-4816) http://git-wip-us.apache.org/repos/asf/cassandra/blob/811359db/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java index 365d7cb..945d2e8 100644 --- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java @@ -1180,8 +1180,10 @@ public class SelectStatement implements CQLStatement if (stmt.isKeyRange) throw new InvalidRequestException("ORDER BY is only supported when the partition key is restricted by an EQ or an IN."); - // check if we are trying to order by column that wouldn't be included in the results - if (!stmt.selectedNames.isEmpty()) // empty means wildcard was used + // If we order an IN query, we'll have to do a manual sort post-query. Currently, this sorting requires that we + // have queried the column on which we sort (TODO: we should update it to add the column on which we sort to the one + // queried automatically, and then removing it from the resultSet afterwards if needed) + if (stmt.keyIsInRelation && !stmt.selectedNames.isEmpty()) // empty means wildcard was used { for (ColumnIdentifier column : stmt.parameters.orderings.keySet()) {
