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

Spaces inserted by PropertyPathBuilder cause problems with AllegroGraph #4923

Closed
reckart opened this issue Mar 1, 2024 · 1 comment · Fixed by #4928
Closed

Spaces inserted by PropertyPathBuilder cause problems with AllegroGraph #4923

reckart opened this issue Mar 1, 2024 · 1 comment · Fixed by #4928
Assignees
Labels
🐞 bug issue is a bug
Milestone

Comments

@reckart
Copy link
Contributor

reckart commented Mar 1, 2024

Current Behavior

When building a property path using PropertyPathBuilder, the path contains spaces, e.g. after operators such as +. It appears that AllegroGraph does not like that.

Looking in the SPARQL specs, it seems that there should not be spaces before postfix operators (like '+') or after prefix operators ('^').

AllegroGraph is the only SPARQL backend I have seen so far that seems to be picky on this issue.

Expected Behavior

PropertyPathBuilder should generate standards-compliant property paths.

Steps To Reproduce

Ok, this is tricky - you'd need an AllegroGraph instance to actually reproduce it. But I'll give you examples.

This query constructed using the RDF4J API fails:

Query   : 
          SELECT DISTINCT ?subj
          FROM <http://testgraph>
          WHERE { { { ?subj <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> + <http://example.org/#property-1> .
          FILTER EXISTS { { ?subj <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . } UNION { ?subj <http://www.w3.org/2000/01/rdf-schema#subClassOf> + <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . } UNION { [] <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?subj . } UNION { ?subj <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> [] . } } } } }
          LIMIT 200

----
org.eclipse.rdf4j.query.QueryEvaluationException: Line 3, Found !<HTTP://EXAMPLE.ORG/#PROPERTY-1> (of type q_iri_ref). Was expecting one of: DECIMAL-POSITIVE, DOUBLE-POSITIVE, INTEGER-POSITIVE. while running query:
SELECT DISTINCT ?subj
FROM <http://testgraph>
WHERE { { { ?subj <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> + <http://example.org/#property-1> .
FILTER EXISTS { { ?subj <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . } UNION { ?subj <http://www.w3.org/2000/01/rdf-schema#subClassOf> + <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . } UNION { [] <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?subj . } UNION { ?subj <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> [] . } } } } }
LIMIT 200

This query works after I have adjusted classes such as org.eclipse.rdf4j.sparqlbuilder.constraint.propertypath.OneOrMorePath to not add a space:

Query   : 
          SELECT DISTINCT ?subj
          FROM <http://testgraph>
          WHERE { { { ?subj <http://www.w3.org/2000/01/rdf-schema#subPropertyOf>+ <http://example.org/#property-1> .
          FILTER EXISTS { { ?subj <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . } UNION { ?subj <http://www.w3.org/2000/01/rdf-schema#subClassOf>+ <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . } UNION { [] <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?subj . } UNION { ?subj <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> [] . } } } } }
          LIMIT 200
Results : 2 in 520ms
          KBHandle[identifier=http://example.org/#subproperty-1-1,name=<null>]
          KBHandle[identifier=http://example.org/#subproperty-1-1-1,name=<null>]

Version

4.3.9

Are you interested in contributing a solution yourself?

Perhaps?

Anything else?

I can provide a PR to remove the spaces, but I'd prefer not having to produce a full unit test for this as this would involve booting up an AllegroGraph, filling it with data and testing queries against it.

Tested against Docker image franzinc/agraph:latest (ID sha256:5c3cf4887ecf832a68fb94360edfae57cf3506d3604864967266362f8a733189)

@tpluscode
Copy link

FYI, I reported this to AllegroGraph this week. Will be fixed in version 8.1.1

reckart added a commit to reckart/rdf4j that referenced this issue Mar 6, 2024
…blems with AllegroGraph

- Removed spaces after prefix operators and before postfix operators
reckart added a commit to reckart/rdf4j that referenced this issue Mar 6, 2024
…blems with AllegroGraph

- Removed spaces after prefix operators and before postfix operators
- Adjusted test cases accordingly
@hmottestad hmottestad added this to the 4.3.11 milestone Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug issue is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants