blazegraph / database

Blazegraph High Performance Graph Database
GNU General Public License v2.0
891 stars 172 forks source link

URI (percent) encoding in SPARQL PrefixedName breaks things #106

Open futpib opened 5 years ago

futpib commented 5 years ago

For example, on wikidata following two queries produce the same result:

SELECT ?cat
WHERE 
{
  ?cat wdt:P31 wd:Q146 .
}
SELECT ?cat
WHERE 
{
  ?cat wdt:P31 wd:%51146 .
}

(Notice %51 as a percent-encoded Q. This is used for example, In reality I face an issue with whitespaces and other non-URI-friendly characters. Query 1. Query 2.)

This is the correct behaviour as you can notice percent encoding in the grammar for PrefixedName.

Blazegraph instead seem to take percent encoding literally.

Let's insert some test data into blazegraph (3):

PREFIX ex: <http://example.com/>
INSERT DATA {
    ex:s ex:p ex:x%20x .
}

Then try to query for it with prefixed URI-encoded object, nothing is returned (4):

PREFIX ex: <http://example.com/>
SELECT ?s ?p WHERE {
    ?s ?p ex:x%20x .
}

If you use the full URI, correct result is returned (5):

PREFIX ex: <http://example.com/>
SELECT ?s ?p WHERE {
    ?s ?p <http://example.com/x%20x> .
}

Blazegraph version: BLAZEGRAPH_RELEASE_CANDIDATE_2_1_5 (via https://github.com/nawerprod/blazegraph/blob/master/2.1.5/Dockerfile)