blazegraph / database

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

Simple string literal is not equal to typed literal with type xsd:string #168

Open rpuch opened 3 years ago

rpuch commented 3 years ago

First, I insert 2 triples to Blazegraph 2.1.5:

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

insert data {
  <http://s> <http://untyped> 'abc' .
  <http://s> <http://typed> 'abc'^^xsd:string .
}

Their object has the same value, but in the first triple it's simple (untyped) and in the second it is explicitly typed as xsd:string.

Then, the following query only finds the first triple:

select * where { ?s ?p 'abc' }

And the following query only finds the second triple:

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

select * where { ?s ?p 'abc'^^xsd:string }

So Blazegraph distinguishes between 'abc' and 'abc'^^xsd:string. But the SPARQL Specification 1.1 (Section 3.3 Literals) https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal says the following:

Simple literals are syntactic sugar for abstract syntax literals with the datatype IRI http://www.w3.org/2001/XMLSchema#string

So either Blazegraph violates SPARQL 1.1, or it does not support SPARQL 1.1, or I misinterpret the specification.

Could you please help me figure out what is the correct answer? :)

Some context https://stackoverflow.com/questions/62771044/jena-fuseki-and-blazegraph-behave-differently-with-respect-to-type-strictness

aindlq commented 3 years ago

I think that 2.1.5 is RDF 1.0. You need to use https://github.com/blazegraph/database/tree/BLAZEGRAPH_RELEASE_CANDIDATE_2_2_0 branch if you need RDF 1.1 (https://github.com/blazegraph/database/issues/57#issuecomment-285889058).

https://oss.sonatype.org/content/repositories/snapshots/com/blazegraph/blazegraph-war/2.2.0-SNAPSHOT/blazegraph-war-2.2.0-20160908.003514-6.war

rpuch commented 3 years ago

I think that 2.1.5 is RDF 1.0. You need to use https://github.com/blazegraph/database/tree/BLAZEGRAPH_RELEASE_CANDIDATE_2_2_0 branch if you need RDF 1.1 (#57 (comment)).

https://oss.sonatype.org/content/repositories/snapshots/com/blazegraph/blazegraph-war/2.2.0-SNAPSHOT/blazegraph-war-2.2.0-20160908.003514-6.war

Thank you @aindlq ! In 2.2.0 RC it really works without explicit type denotation, like in Fuseki. But it's a bit scary to use a non-released RC in production environment...