Accept empty selections in ColumnFilter builder

patch by slebresne; reviewed by aweisberg for CASSANDRA-10471

The builder for ColumnFilter was asserting that the built selection was
at least selection one column. But some empty IN queries actually
select nothing and so that assertion was triggered on some tests.
The patch modify the builder so it accepts that case and return an
empty filter as expected.


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/9aefe13a
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/9aefe13a
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/9aefe13a

Branch: refs/heads/trunk
Commit: 9aefe13abd2fae9067e58027079e1959bf897e9b
Parents: 56cfc6e
Author: Sylvain Lebresne <sylv...@datastax.com>
Authored: Tue Oct 13 12:10:33 2015 +0200
Committer: Sylvain Lebresne <sylv...@datastax.com>
Committed: Fri Oct 16 14:45:21 2015 +0200

----------------------------------------------------------------------
 CHANGES.txt                                               | 1 +
 src/java/org/apache/cassandra/db/filter/ColumnFilter.java | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9aefe13a/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6bdaa04..a53a299 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0-rc2
+ * Support empty ColumnFilter for backward compatility on empty IN 
(CASSANDRA-10471)
  * Remove Pig support (CASSANDRA-10542)
  * Fix LogFile throws Exception when assertion is disabled (CASSANDRA-10522)
  * Revert CASSANDRA-7486, make CMS default GC, move GC config to

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9aefe13a/src/java/org/apache/cassandra/db/filter/ColumnFilter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/filter/ColumnFilter.java 
b/src/java/org/apache/cassandra/db/filter/ColumnFilter.java
index 1a4573e..62329ab 100644
--- a/src/java/org/apache/cassandra/db/filter/ColumnFilter.java
+++ b/src/java/org/apache/cassandra/db/filter/ColumnFilter.java
@@ -289,7 +289,12 @@ public class ColumnFilter
         public ColumnFilter build()
         {
             boolean isFetchAll = metadata != null;
-            assert isFetchAll || selection != null;
+
+            PartitionColumns selectedColumns = selection == null ? null : 
selection.build();
+            // It's only ok to have selection == null in ColumnFilter if 
isFetchAll. So deal with the case of a "selection" builder
+            // with nothing selected (we can at least happen on some backward 
compatible queries - CASSANDRA-10471).
+            if (!isFetchAll && selectedColumns == null)
+                selectedColumns = PartitionColumns.NONE;
 
             SortedSetMultimap<ColumnIdentifier, ColumnSubselection> s = null;
             if (subSelections != null)
@@ -299,7 +304,7 @@ public class ColumnFilter
                     s.put(subSelection.column().name, subSelection);
             }
 
-            return new ColumnFilter(isFetchAll, metadata, selection == null ? 
null : selection.build(), s);
+            return new ColumnFilter(isFetchAll, metadata, selectedColumns, s);
         }
     }
 

Reply via email to