Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support BIND in SparqlQueryRenderer #71

Closed
2 of 5 tasks
abrokenjester opened this issue May 11, 2016 · 7 comments · Fixed by #2987 · May be fixed by JervenBolleman/rdf4j#2
Closed
2 of 5 tasks

Support BIND in SparqlQueryRenderer #71

abrokenjester opened this issue May 11, 2016 · 7 comments · Fixed by #2987 · May be fixed by JervenBolleman/rdf4j#2
Assignees
Labels
📶 enhancement issue is a new feature or improvement 📦 sparql affects the SPARQL parser / engine specification issues related to compliance to standards and external specs
Milestone

Comments

@abrokenjester
Copy link
Contributor

abrokenjester commented May 11, 2016

(Migrated from https://openrdf.atlassian.net/browse/SES-2206 )

SPARQL 1.1 constructs cannot be rendered via the SparqlQueryRenderer class.

Subtasks

Examples

For example If I parse this query with QueryParserUtil.parseQuery:

SELECT \* WHERE {
  ?s ?p ?o .
  BIND(uri("http://test-graph.com/") AS ?foo) .
}

And then render the ParsedQuery back out again with SPARQLQueryRenderer, it appears to lose the binding clause, returning the following string:

select ?g ?s ?p ?o ?g2
where {
  GRAPH ?g {
    ?s ?p ?o.
}}

Looking at renderTupleExpr in SparqlTupleExprRenderer I can see that the following lines are commented out:

    // aRenderer.mProjection = new ArrayList<ProjectionElemList>(mProjection);
    // aRenderer.mDistinct = mDistinct;
    // aRenderer.mReduced = mReduced;
    // aRenderer.mExtensions = new HashMap<String, ValueExpr>(mExtensions);
    // aRenderer.mOrdering = new ArrayList<OrderElem>(mOrdering);
    // aRenderer.mLimit = mLimit;
    // aRenderer.mOffset = mOffset;

With the following commented out in SPARQLQueryRenderer:

                    // SPARQL does not support this, its an artifact of copy and
                    // paste from the serql stuff
                    // aQuery.append(mRenderer.getExtensions().containsKey(aElem.getSourceName())
                    // ?
                    // mRenderer.renderValueExpr(mRenderer.getExtensions().get(aElem.getSourceName()))
                    // : "?"+aElem.getSourceName());
                    //
                    // if (!aElem.getSourceName().equals(aElem.getTargetName()) ||
                    // (mRenderer.getExtensions().containsKey(aElem.getTargetName())
                    // &&
                    // !mRenderer.getExtensions().containsKey(aElem.getSourceName())))
                    // {
                    // aQuery.append(" as ").append(mRenderer.getExtensions().containsKey(aElem.getTargetName())
                    // ?
                    // mRenderer.renderValueExpr(mRenderer.getExtensions().get(aElem.getTargetName()))
                    // : aElem.getTargetName());
                    // }

I believe these lines are commented out in error and that they should be commented back in in order to get be able to round trip queries from SPARQL text into the AST and back out again.

Other SPARQL 1.1 queries that fail include:

SELECT (COUNT (*) as ?c) WHERE { ?s ?p ?o }

is rendered as

select ?c where { ?s ?p ?o }

and the query

SELECT (?p as ?x) WHERE { ?s ?p ?o }

is rendered as

select ?p WHERE { ?s ?p ?o }

@abrokenjester abrokenjester added the 📶 enhancement issue is a new feature or improvement label May 11, 2016
@abrokenjester abrokenjester added the help wanted we could use your help in fixing this issue label Jan 18, 2017
@abrokenjester
Copy link
Contributor Author

The basic problem is that the QueryRenderer was implemented against the SPARQL 1.0 standard, and has never been extended to include the new SPARQL 1.1 features (even though RDF4J's query engine fully supports SPARQL 1.1). The renderer should be extended to be able to process these features.

@catch-point catch-point added the specification issues related to compliance to standards and external specs label Jun 23, 2017
@abrokenjester
Copy link
Contributor Author

We need to have a discussion about the query render and the query builder tools, and the newly integrated spanqit module.

@abrokenjester abrokenjester added the stale issue has gone stale (close reason) label May 6, 2018
@abrokenjester abrokenjester added wontfix issue won't be fixed (close reason) needs discussion stale issue has gone stale (close reason) and removed needs discussion stale issue has gone stale (close reason) wontfix issue won't be fixed (close reason) labels Jul 9, 2018
@timbaer
Copy link

timbaer commented Aug 18, 2018

Hi evrybody,

so as this ticket is not discussed by any means, is there any way to create an AST based on a SPARQL Query, modify it, and transform it back to SPARQL? I believe this is a very viable feature for this project.

Regards

@abrokenjester
Copy link
Contributor Author

Creating an AST from a query is what the SPARQL parser package (specifically the class org.eclipse.rdf4j.query.parser.sparq.ast.SyntaxTreeBuilder) does. There's support for modifying it as well through the SyntaxTreeBuilderVisitor interface.

The only thing we don't really have full support for is serializing an AST back into a SPARQL query string. The SparqlQueryRenderer discussed in this issue has partial support, but as the ticket says, it's never been updated to deal with SPARQL 1.1.

@abrokenjester abrokenjester removed needs discussion stale issue has gone stale (close reason) labels Feb 17, 2019
abrokenjester pushed a commit that referenced this issue Aug 22, 2019
Signed-off-by: Andreas Schwarte <aschwarte10@gmail.com>
abrokenjester added a commit that referenced this issue Aug 22, 2019
Signed-off-by: Jeen Broekstra <jeen.broekstra@gmail.com>
abrokenjester pushed a commit that referenced this issue Aug 22, 2019
Use the new replacement for the cluster health check w.r.t waiting for
relocating shards

Signed-off-by: Andreas Schwarte <aschwarte10@gmail.com>
abrokenjester pushed a commit that referenced this issue Aug 22, 2019
We need to use lucene 6.6.1 explicitly as there is a version check
(assertion) in elasticsearch 5.6.9.

In addition, the elasticsearch compliance test needs to be run with the
Java security manager disabled. Also the "JarHell" class needs to be
overridden with no-ops in order to make the test work with the classpath
and all the transitive dependencies.


Signed-off-by: Andreas Schwarte <aschwarte10@gmail.com>
abrokenjester pushed a commit that referenced this issue Aug 22, 2019
Backwards codecs can be used to read indices created with an older
lucene version

Signed-off-by: Andreas Schwarte <aschwarte10@gmail.com>
abrokenjester pushed a commit that referenced this issue Aug 22, 2019
Fix #71: Update Lucene, Solr and Elasticsearch dependencies
abrokenjester pushed a commit that referenced this issue Aug 22, 2019
Upgrade components

Lucene: 6.6.1 -> 7.2.1
Elasticsearch: 5.6.9 -> 6.2.4
Solr: 6.6.1 -> 7.2.1

Note: we cannot upgrade to lucene 7.3.1 as elasticsearch has a
strict version dependency on 7.2.1. Also spatial4j cannot seamlessly be
upgraded

Signed-off-by: Andreas Schwarte <aschwarte10@gmail.com>
abrokenjester added a commit that referenced this issue Aug 22, 2019
…optional/runtime

Signed-off-by: Jeen Broekstra <jeen.broekstra@gmail.com>
@abrokenjester abrokenjester removed the help wanted we could use your help in fixing this issue label Apr 10, 2020
abrokenjester pushed a commit that referenced this issue Jul 25, 2020
…rial

fixed typos and clarified a few things
@abrokenjester abrokenjester reopened this Apr 8, 2021
RedCrusaderJr added a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 13, 2021
RedCrusaderJr pushed a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 15, 2021
…D sparql query

Signed-off-by: Jerven bolleman <jerven.bolleman@sib.swiss>
RedCrusaderJr added a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 15, 2021
RedCrusaderJr added a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 15, 2021
… for simple ArbitraryLengthPath case

Supported:
function call inside BIND
rdfs:subClassOf+ (ArbitraryLengthPath case)
RedCrusaderJr added a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 15, 2021
RedCrusaderJr added a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 15, 2021
abrokenjester pushed a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 15, 2021
…D sparql query

Signed-off-by: Jerven bolleman <jerven.bolleman@sib.swiss>
abrokenjester pushed a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 15, 2021
abrokenjester pushed a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 15, 2021
… for simple ArbitraryLengthPath case

Supported:
function call inside BIND
rdfs:subClassOf+ (ArbitraryLengthPath case)
abrokenjester pushed a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 15, 2021
abrokenjester pushed a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 15, 2021
@abrokenjester abrokenjester added the epic large issue consisting of multiple sub-tasks label Apr 17, 2021
RedCrusaderJr added a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 17, 2021
…rting some additional functions

STILL NOT SUPPORTED functions:
coalesce
exists / not exists
in / not in
bnode
RedCrusaderJr added a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 17, 2021
abrokenjester added a commit to RedCrusaderJr/rdf4j that referenced this issue Apr 18, 2021
abrokenjester added a commit that referenced this issue Apr 18, 2021
GH-71 render bind clause with SPARQLQueryRenderer
@abrokenjester
Copy link
Contributor Author

Thanks @RedCrusaderJr, your fix for BIND has been merged in!

I am planning to pick up further improvements as subtasks of this issue.

@abrokenjester abrokenjester changed the title Support BIND (and other SPARQL 1.1 constructs) in SparqlQueryRenderer Support BIND in SparqlQueryRenderer May 25, 2021
@abrokenjester abrokenjester removed the epic large issue consisting of multiple sub-tasks label May 25, 2021
@abrokenjester
Copy link
Contributor Author

Closing this as complete, further improvements will be taken care of as followup tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📶 enhancement issue is a new feature or improvement 📦 sparql affects the SPARQL parser / engine specification issues related to compliance to standards and external specs
Projects
None yet
3 participants