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.
This commit is contained in:
Sylvain Lebresne 2015-10-13 12:10:33 +02:00
parent 56cfc6ea35
commit 9aefe13abd
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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);
}
}