From 9aefe13abd2fae9067e58027079e1959bf897e9b Mon Sep 17 00:00:00 2001 From: Sylvain Lebresne Date: Tue, 13 Oct 2015 12:10:33 +0200 Subject: [PATCH] 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. --- CHANGES.txt | 1 + .../org/apache/cassandra/db/filter/ColumnFilter.java | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 6bdaa04444..a53a29908e 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 diff --git a/src/java/org/apache/cassandra/db/filter/ColumnFilter.java b/src/java/org/apache/cassandra/db/filter/ColumnFilter.java index 1a4573e8f1..62329ab050 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 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); } }