Broken SPARQL Turtle/TriG for xsd:double

When querying a negative xsd:double literal value via SPARQL an error occurs.

  • initial data (data.nt):

    <https://example.org/double> <https://example.org/value> "-0.03129"^^<http://www.w3.org/2001/XMLSchema#double> .
    
  • querying via CLI produces an error:

    $ stardog query db "CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o}"
    Object for statement missing [line 1]
    
  • querying via Query Panel (http://localhost:5820/db#!/query + CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o}) and export as Turtle results in corrupt data:

    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    
    <https://example.org/double> <https://example.org/value> ..03129E-1 .
    
  • querying via Query Panel (http://localhost:5820/db#!/query + CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o}) and export as TriG results in corrupt data:

    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    
    {
        <https://example.org/double> <https://example.org/value> ..03129E-1 .
    }
    

Steps to reproduce

  1. start Stardog

    $ stardog-admin server start
    
  2. create database

    $ stardog-admin db create -n db data.nt
    

Other export methods

Other export methods work as expected:

  • export using SPARQL Graph Store Protocol:

    $ curl "http://localhost:5820/db?default" -H "Accept: text/turtle" -u admin:admin
    @prefix : <http://api.stardog.com/> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix stardog: <tag:stardog:api:> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    
    <https://example.org/double> <https://example.org/value> -3.129E-2 .
    
  • export using CLI (Turtle):

    $ stardog data export --format TURTLE db export.ttl; cat export.ttl
    Exported data as Turtle to file 'export.ttl' in 39.92 ms.
    @prefix : <http://api.stardog.com/> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix stardog: <tag:stardog:api:> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    
    <https://example.org/double> <https://example.org/value> -3.129E-2 .
    
  • export using CLI (TriG):

    $ stardog data export --format TRIG db export.trig; cat export.trig
    Exported data as TriG to file 'export.trig' in 39.05 ms.
    @prefix : <http://api.stardog.com/> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix stardog: <tag:stardog:api:> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    
    {
        <https://example.org/double> <https://example.org/value> -3.129E-2 .
    }
    

Additional information

Stardog version: 5.0-RC1

I have checked the used OpenRDF/Sesame/RDF4J version for Stardog 4.2.3: org.openrdf.sesame:sesame-rio-turtle:4.0.0.

With version 4.0.2 the problem does not exist.

The release notes of Stardog 5.0 state:

Wrong formatting of doubles between -1 and 0 in CONSTRUCT queries (#3891)

Is this the same error?

Yes, that line in the release notes refers to this issue. Are you still seeing this behavior?

I just tried to reproduce the problem following the steps provided by @depressiveRobot using Stardog version 5.0.1 and the error didn’t occur, so it’s fixed :smiley:

I have the same problem when I export the SPARQL query result from an rdf file to csv format, for example the -0.50986 value will be …50986E-1 in my CSV file. How to reselve this problem in Stardog 5.1.

Apologies for the (very) delayed response here… the problem with these results appearing in CSV SPARQL results has been fixed as of Stardog 5.3.0. I would suggest you update to address this.