You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@marmotta.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/04/09 23:26:41 UTC

[jira] [Commented] (MARMOTTA-657) SPARQL query GROUP BY with ORDER BY clause fails

    [ https://issues.apache.org/jira/browse/MARMOTTA-657?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15962302#comment-15962302 ] 

ASF GitHub Bot commented on MARMOTTA-657:
-----------------------------------------

GitHub user gmora1223 opened a pull request:

    https://github.com/apache/marmotta/pull/27

    Solved MARMOTTA-657 - SPARQL query GROUP BY with ORDER BY clause fails.

    When building a SQL query, GROUP BY statements allow aggregate functions. This was solved comparing if an statement from ORDER BY is not an aggregate funtion, then add if not continue. This PR solves MARMOTTA-657.
    
    Be sure to do all of the following to help us incorporate your contribution quickly and easily:
    
     - [x] Make sure the PR title is formatted like: `MARMOTTA-XXX: title of pull request`
       (replace `XXX` in the title with the actual Jira issue number; if there is no one,
       please [create one](https://issues.apache.org/jira/browse/MARMOTTA) before).
     - [x] Make sure tests pass via mvn clean verify (even better, enable Travis-CI on your
       fork and ensure the whole test suite passes).
     - [ ] If this contribution is large, please file an 
       [Apache's Individual Contributor License Agreement](https://www.apache.org/licenses/icla.txt).
    
    ---
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/gmora1223/marmotta MARMOTTA-657

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/marmotta/pull/27.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #27
    
----
commit 9abcdd92f3e1615bf7c98540ecc2d9d776313f73
Author: gmora1223 <gm...@gmail.com>
Date:   2017-04-09T22:44:17Z

    Solved MARMOTTA-657 - SPARQL query GROUP BY with ORDER BY clause fails.
    
    When building a SQL query, GROUP BY statements allow aggregate functions. This was solved comparing if an statement from ORDER BY is not an aggregate funtion, then add if not continue.
    
    Signed-off-by: Gustavo Mora <gm...@gmail.com>

----


> SPARQL query GROUP BY with ORDER BY clause fails
> ------------------------------------------------
>
>                 Key: MARMOTTA-657
>                 URL: https://issues.apache.org/jira/browse/MARMOTTA-657
>             Project: Marmotta
>          Issue Type: Bug
>    Affects Versions: 3.4.0
>         Environment: Ubuntu 16.04
> PostgreSQL 9.5.4 (empty database)
> openjdk version "1.8.0_91"
> OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~16.04.1-b14)
> OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
>            Reporter: Osma Suominen
>              Labels: sparql
>             Fix For: 3.4.0
>
>
> I noticed that the following SPARQL query, used to count the number of triples in different graphs, fails on the current 3.4.0-SNAPSHOT (using PostgreSQL 9.5 as backend, starting from an empty database). It works on 3.3.0 using the same database.
> {noformat}
> SELECT ?g (COUNT(*) AS ?c) {
>   GRAPH ?g {
>     ?s ?p ?o
>   }
> }
> GROUP BY ?g
> ORDER BY DESC(?c)
> {noformat}
> The error in the Tomcat log is:
> {noformat}
> 09:32:30.101 ERROR - error while evaluating query: {}
> org.openrdf.query.QueryEvaluationException: org.postgresql.util.PSQLException: ERROR: aggregate functions are not allowed in GROUP BY
>   Position: 183
>         at org.openrdf.repository.sail.SailTupleQuery.evaluate(SailTupleQuery.java:67)
>         at org.openrdf.repository.sail.SailTupleQuery.evaluate(SailTupleQuery.java:75)
>         at org.apache.marmotta.platform.sparql.services.sparql.SparqlServiceImpl.query(SparqlServiceImpl.java:344)
>         at org.apache.marmotta.platform.sparql.services.sparql.SparqlServiceImpl.query(SparqlServiceImpl.java:351)
>         at org.apache.marmotta.platform.sparql.services.sparql.SparqlServiceImpl.access$700(SparqlServiceImpl.java:60)
>         at org.apache.marmotta.platform.sparql.services.sparql.SparqlServiceImpl$5.call(SparqlServiceImpl.java:290)
>         at org.apache.marmotta.platform.sparql.services.sparql.SparqlServiceImpl$5.call(SparqlServiceImpl.java:279)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>         at java.lang.Thread.run(Thread.java:745)
> Caused by: org.openrdf.sail.SailException: org.postgresql.util.PSQLException: ERROR: aggregate functions are not allowed in GROUP BY
>   Position: 183
>         at org.apache.marmotta.kiwi.sparql.sail.KiWiSparqlSailConnection.evaluate(KiWiSparqlSailConnection.java:101)
>         at org.openrdf.sail.helpers.SailConnectionWrapper.evaluate(SailConnectionWrapper.java:95)
>         at org.openrdf.repository.sail.SailTupleQuery.evaluate(SailTupleQuery.java:60)
>         ... 10 common frames omitted
> Caused by: org.openrdf.query.QueryEvaluationException: org.postgresql.util.PSQLException: ERROR: aggregate functions are not allowed in GROUP BY
>   Position: 183
>         at org.apache.marmotta.kiwi.sparql.evaluation.KiWiEvaluationStrategy.evaluateNative(KiWiEvaluationStrategy.java:398)
>         at org.apache.marmotta.kiwi.sparql.evaluation.KiWiEvaluationStrategy.evaluate(KiWiEvaluationStrategy.java:133)
>         at org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl.evaluate(EvaluationStrategyImpl.java:616)
>         at org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl.evaluate(EvaluationStrategyImpl.java:207)
>         at org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl.evaluate(EvaluationStrategyImpl.java:687)
>         at org.apache.marmotta.kiwi.sparql.evaluation.KiWiEvaluationStrategy.evaluate(KiWiEvaluationStrategy.java:108)
>         at org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl.evaluate(EvaluationStrategyImpl.java:589)
>         at org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl.evaluate(EvaluationStrategyImpl.java:207)
>         at org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl.evaluate(EvaluationStrategyImpl.java:621)
>         at org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl.evaluate(EvaluationStrategyImpl.java:207)
>         at org.apache.marmotta.kiwi.sparql.sail.KiWiSparqlSailConnection.evaluate(KiWiSparqlSailConnection.java:98)
>         ... 12 common frames omitted
> Caused by: org.postgresql.util.PSQLException: ERROR: aggregate functions are not allowed in GROUP BY
>   Position: 183
>         at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
>         at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
>         at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
>         at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:560)
>         at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
>         at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:302)
>         at org.apache.marmotta.kiwi.sparql.evaluation.KiWiEvaluationStrategy$1.call(KiWiEvaluationStrategy.java:217)
>         at org.apache.marmotta.kiwi.sparql.evaluation.KiWiEvaluationStrategy$1.call(KiWiEvaluationStrategy.java:213)
>         ... 4 common frames omitted
> {noformat}
> Originally reported on users@marmotta: https://lists.apache.org/thread.html/7df333d6678a853e0ae013178660a78cd7bc5438caaf8ee207ff643f@%3Cusers.marmotta.apache.org%3E



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)