Github user cuent commented on a diff in the pull request:
https://github.com/apache/marmotta/pull/27#discussion_r111057387
--- Diff:
libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLBuilder.java
---
@@ -796,13 +848,13 @@ private StringBuilder buildGroupClause() {
}
if (orderby.size() > 0) {
- groupClause.append(", ");
for(Iterator<OrderElem> it = orderby.iterator();
it.hasNext(); ) {
OrderElem elem = it.next();
- groupClause.append(evaluateExpression(elem.getExpr(),
ValueType.STRING));
- if (it.hasNext()) {
- groupClause.append(", ");
+ String expr = evaluateExpression(elem.getExpr(),
ValueType.STRING);
+ if (StringUtils.indexOfAny(expr, aggregateFuncs) !=
-1) {
+ continue;
}
+ groupClause.append(", ").append(expr);
--- End diff --
Another option to avoid aggregation functions.
- **Disadvantage** Longer code.
- **Advantage** Don't need to use a specific list.
```java
if (orderby.size() > 0) {
for(Iterator<OrderElem> it = orderby.iterator();
it.hasNext(); ) {
OrderElem elem = it.next();
ValueExpr expr = elem.getExpr();
if (expr instanceof Var){
Var var = (Var)expr;
SQLVariable sv = variables.get(var.getName());
List<ValueExpr> bindings1 = sv.getBindings();
if (bindings1!= null)
{
boolean aggregateOpPresent=false;
for (ValueExpr vexpr: bindings1){
if (vexpr instanceof AggregateOperator){
aggregateOpPresent=true;
break;
}
}
if (aggregateOpPresent){
continue;
}
}
}
groupClause.append(",
").append(evaluateExpression(expr, ValueType.STRING));
}
}
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---