Merge cassandra-2.2 into cassandra-3.0 Conflicts: src/java/org/apache/cassandra/cql3/Cql.g
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/1964a82b Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/1964a82b Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/1964a82b Branch: refs/heads/cassandra-3.0 Commit: 1964a82bf0dea261ccb1f48c36cda0de7fa8d62e Parents: be2c26f 4fc5851 Author: blerer <benjamin.le...@datastax.com> Authored: Thu Aug 20 14:10:11 2015 +0200 Committer: blerer <benjamin.le...@datastax.com> Committed: Thu Aug 20 14:10:11 2015 +0200 ---------------------------------------------------------------------- NEWS.txt | 1 + src/java/org/apache/cassandra/cql3/Cql.g | 9 +---- .../cassandra/cql3/functions/AggregateFcts.java | 11 ++++++ .../selection/AbstractFunctionSelector.java | 6 +++ .../cassandra/cql3/selection/Selector.java | 1 - .../validation/operations/AggregationTest.java | 39 ++++++++++++++++++++ 6 files changed, 59 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/1964a82b/NEWS.txt ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/1964a82b/src/java/org/apache/cassandra/cql3/Cql.g ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/1964a82b/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java index 153e5eb,41e43c0..7b5bdb8 --- a/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java +++ b/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java @@@ -32,47 -37,18 +32,58 @@@ import org.apache.cassandra.db.marshal. */ public abstract class AggregateFcts { + public static Collection<AggregateFunction> all() + { + Collection<AggregateFunction> functions = new ArrayList<>(); + + functions.add(countRowsFunction); + + // sum for primitives + functions.add(sumFunctionForByte); + functions.add(sumFunctionForShort); + functions.add(sumFunctionForInt32); + functions.add(sumFunctionForLong); + functions.add(sumFunctionForFloat); + functions.add(sumFunctionForDouble); + functions.add(sumFunctionForDecimal); + functions.add(sumFunctionForVarint); + + // avg for primitives + functions.add(avgFunctionForByte); + functions.add(avgFunctionForShort); + functions.add(avgFunctionForInt32); + functions.add(avgFunctionForLong); + functions.add(avgFunctionForFloat); + functions.add(avgFunctionForDouble); + functions.add(avgFunctionForDecimal); + functions.add(avgFunctionForVarint); + + // count, max, and min for all standard types + for (CQL3Type type : CQL3Type.Native.values()) + { + if (type != CQL3Type.Native.VARCHAR) // varchar and text both mapping to UTF8Type + { + functions.add(AggregateFcts.makeCountFunction(type.getType())); + functions.add(AggregateFcts.makeMaxFunction(type.getType())); + functions.add(AggregateFcts.makeMinFunction(type.getType())); + } + } + + return functions; + } + /** + * Checks if the specified function is the count rows (e.g. COUNT(*) or COUNT(1)) function. + * + * @param function the function to check + * @return <code>true</code> if the specified function is the count rows one, <code>false</code> otherwise. + */ + public static boolean isCountRows(Function function) + { + return function == countRowsFunction; + } + + /** * The function used to count the number of rows of a result set. This function is called when COUNT(*) or COUNT(1) * is specified. */ http://git-wip-us.apache.org/repos/asf/cassandra/blob/1964a82b/src/java/org/apache/cassandra/cql3/selection/Selector.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/1964a82b/test/unit/org/apache/cassandra/cql3/validation/operations/AggregationTest.java ----------------------------------------------------------------------