Skip to content

Commit

Permalink
Fixes #650 - issue when doing multiple aggregation expressions on the…
Browse files Browse the repository at this point in the history
… same identifier
  • Loading branch information
systay committed Mar 26, 2013
1 parent 831e02c commit 8348fae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions community/cypher/CHANGES.txt
Expand Up @@ -4,6 +4,7 @@ o Fixed #578 - problem with profiling queries that use LIMIT
o Fixes #550 - problem when using START after WITH
o Allows single node patterns in MATCH
o Fixes problem for some patterns and all-nodes start points
o Fixes #650 - issue when doing multiple aggregation expressions on the same identifier

1.9.M05 (2013-03-05)
--------------------
Expand Down
Expand Up @@ -19,11 +19,12 @@
*/
package org.neo4j.cypher.internal.executionplan.builders

import org.neo4j.cypher.internal.pipes.{Pipe, ExtractPipe, EagerAggregationPipe}
import org.neo4j.cypher.internal.pipes.EagerAggregationPipe
import org.neo4j.cypher.internal.executionplan.{PartiallySolvedQuery, ExecutionPlanInProgress, PlanBuilder}
import org.neo4j.cypher.internal.commands.expressions.{Identifier, CachedExpression, AggregationExpression, Expression}
import org.neo4j.cypher.internal.commands.expressions.{CachedExpression, AggregationExpression, Expression}
import org.neo4j.cypher.internal.symbols.SymbolTable
import org.neo4j.cypher.internal.commands.ReturnItem
import java.util.UUID


/*
Expand Down Expand Up @@ -54,7 +55,8 @@ class AggregationBuilder extends PlanBuilder {

// Get the aggregate expressions to calculate, and their named key expressions
val expressions = getExpressions(planToAggregate)
val namedAggregates = expressions.aggregates.map( exp => " INTERNAL_AGGREGATE" + exp.hashCode -> exp ).toMap
val seq = expressions.aggregates.map(exp => " INTERNAL_AGGREGATE" + UUID.randomUUID() -> exp).toList
val namedAggregates = seq.toMap

val resultPipe = new EagerAggregationPipe(planToAggregate.pipe, expressions.keys, namedAggregates)

Expand Down
Expand Up @@ -2476,5 +2476,13 @@ RETURN x0.name?
assert(result.toList === List(Map("p" -> PathImpl(n))))
}

@Test
def should_handle_multiple_aggregates_on_the_same_node() {
//WHEN
val result = parseAndExecute("start n=node(*) return count(n), collect(n)")

//THEN
assert(result.toList === List(Map("count(n)" -> 1, "collect(n)" -> Seq(refNode))))
}

}

0 comments on commit 8348fae

Please sign in to comment.