]
Adrian Nistor updated ISPN-6076:
--------------------------------
Status: Pull Request Sent (was: Coding In Progress)
Git Pull Request:
Errors when the same column is both a gouping column and an
aggregation column
------------------------------------------------------------------------------
Key: ISPN-6076
URL:
https://issues.jboss.org/browse/ISPN-6076
Project: Infinispan
Issue Type: Bug
Components: Embedded Querying
Affects Versions: 8.0.2.Final
Reporter: Adrian Nistor
Assignee: Adrian Nistor
Fix For: 8.2.0.Beta1, 8.2.0.Final
This should not be allowed.
{code}
public void testGroupingAndAggregationOnSameField() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.select(Expression.count("surname"),
Expression.sum("addresses.number"))
.groupBy("surname")
.build();
List<Object[]> list = q.list(); // throws ClassCastException
}
{code}
{code}
java.lang.ClassCastException: java.lang.String cannot be cast to
org.infinispan.objectfilter.impl.aggregation.Counter
at
org.infinispan.objectfilter.impl.aggregation.CountAccumulator.merge(CountAccumulator.java:24)
at
org.infinispan.objectfilter.impl.aggregation.FieldAccumulator.merge(FieldAccumulator.java:42)
at org.infinispan.objectfilter.impl.aggregation.Grouper.addRow(Grouper.java:133)
at
org.infinispan.query.dsl.embedded.impl.AggregatingQuery.getBaseIterator(AggregatingQuery.java:52)
at
org.infinispan.query.dsl.embedded.impl.HybridQuery$1.<init>(HybridQuery.java:47)
at org.infinispan.query.dsl.embedded.impl.HybridQuery.getIterator(HybridQuery.java:45)
at
org.infinispan.query.dsl.embedded.impl.BaseEmbeddedQuery.listInternal(BaseEmbeddedQuery.java:65)
at
org.infinispan.query.dsl.embedded.impl.BaseEmbeddedQuery.list(BaseEmbeddedQuery.java:57)
at org.infinispan.query.dsl.embedded.impl.DelegatingQuery.list(DelegatingQuery.java:45)
at
org.infinispan.query.dsl.embedded.QueryDslConditionsTest.testEmbeddedSum(QueryDslConditionsTest.java:1959)
{code}