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

SPARQL Subquey parse error #2684

Open
hussien opened this issue Jan 11, 2024 · 5 comments
Open

SPARQL Subquey parse error #2684

hussien opened this issue Jan 11, 2024 · 5 comments

Comments

@hussien
Copy link

hussien commented Jan 11, 2024

I am trying to parse the following SPARQL query using Python versions (rdflib 6.2.0, pyparsing 3.0.9) and rdflib-7.0.0
where I face the following error:

  • line 1536, in parseQuery
  • line 1141, in parse_string
  • pyparsing.exceptions.ParseException: Expected {SelectQuery | ConstructQuery | DescribeQuery | AskQuery}, found '{' (at char 116), (line:5, col:21)
select  (count(*) as ?s)
where
{
    ?s ?p ?o.
    {
        select distinct ?s
        from <http://wikikg-v2>
        where
        {
           ?s <http://www.wikidata.org/entity/P69> ?o.
           ?s a "human".
           ?o <http://schema.org/description> ?ol.
        }
    }
}

Your help is appreciated

@WhiteGobo
Copy link
Contributor

You cant specifiy another default graph in a subquery. You could use a federated query instead, but i dont know if you can generate an endpoint locally.

Your query then would look something like this:

SELECT (count(*) as ?s)
WHERE { 
    ?s ?p ?o.
    SERVICE <http://wikikg-v2/> {
        ?s <http://www.wikidata.org/entity/P69> ?o.
        ?s a "human".
        ?o <http://schema.org/description> ?ol.
    }
} 

@WhiteGobo
Copy link
Contributor

or maybe sparql* could do this. But this might take some time. See #1554

@hussien
Copy link
Author

hussien commented Jan 15, 2024

Thanks a lot, Actually my query is selecting from the same default graph so I moved the from statement to the outer query only and it works:

select (count(*) as ?s)
from <http://wikikg-v2/>
where
{
  ?s ?p ?o.
  {
      select distinct ?s
      where
      {
        ?s <http://www.wikidata.org/entity/P69> ?o.
        ?s a "human".
        ?o <http://schema.org/description> ?ol.
      }
  }
}

@WhiteGobo
Copy link
Contributor

I think this issue should be closed

@hussien
Copy link
Author

hussien commented Mar 23, 2024

I think this issue should be closed

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants