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

Optional keyword does not seem to work #1316

Open
pietervdvn opened this issue Mar 28, 2024 · 7 comments
Open

Optional keyword does not seem to work #1316

pietervdvn opened this issue Mar 28, 2024 · 7 comments

Comments

@pietervdvn
Copy link

Issue type:

  • ❓ Question

Question:

I have two json-lds. They both graphs, each containing a geocoordinate (with schema.org/geo). Optionally, they might also contain a 'shape' property defining a Polygon.

I'm trying to extract the shape if there is one with a comunica sparql query, which is more or less:

SELECT * WHERE {
?parking a <http://schema.mobivoc.org/BicycleParkingStation>.
        GRAPH ?g {
            VALUES ?type { vpt:BicycleLocker vpt:BicycleStand vpt:ResidentBicycleParking vpt:PublicBicycleParking }.
            ?section a ?type.
            
            OPTIONAL {
                ?section schema:geo [
                    a schema:GeoCoordinates ;
                    schema:latitude ?latitude ;
                    schema:longitude ?longitude
                ] }.
            OPTIONAL {
                ?x schema:geo [
                a schema:GeoShape ;
                schema:polygon ?shape
                ]
            }.
       }
}

However, this result does not give any bindings if there is no geoshape present - even though this is wrapped into an optional.

When using the link-traversal-build with lenient: true as option, this suddenly works.

You can reproduce this issue; I've made a (more or less) minimal example here:
https://github.com/pietervdvn/sparql-test

Copy link

Someone will answer your question soon. In the meantime, you might be able to get help more quickly on our Gitter channel.

@rubensworks
Copy link
Member

I see you're using Comunica v3. Could you try it out on the latest v2 version (2.10.2) to check if the problem already existed back then? (might be a regression in v3)

@pietervdvn
Copy link
Author

I used a 2.10 version previously, which had the same symptoms.

@rubensworks
Copy link
Member

I see. Very surprising that it does work with link traversal though.

Could you check what happens if you move the data to the default graph and remove the GRAPH keyword from the query? Perhaps that's related as well.

@pietervdvn
Copy link
Author

I added a version without graph-embedding in my minimal test case: https://github.com/pietervdvn/sparql-test

This one works and gives results as expected.

However, I'm reusing data from an upstream provider where I cannot really change the shape of the data they provide...

@rubensworks
Copy link
Member

Hmm, that's interesting.
Could you try querying the graph-based data in a Turtle format? Because I somehow expect it having to do with JSON-LD parsing, and not the actual query processor.

@pietervdvn
Copy link
Author

I'm not really sure how to convert this efficiently to TTL. This website ignored everything within the graph.

However, I did a simple test query ( ?s ?p ?. GRAPH ?g { ?sg ?pg ?og }) and all the expected values are there.

@rubensworks rubensworks moved this from Triage to To Do (prio:high) in Maintenance Apr 19, 2024
@rubensworks rubensworks moved this from To Do (prio:high) to To Do (prio:medium) in Maintenance May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Maintenance
  
To Do (prio:medium)
Development

No branches or pull requests

2 participants