chrdebru / r2rml

MIT License
30 stars 20 forks source link

Error parsing rr:termType #10

Closed arenas-guerrero-julian closed 3 years ago

arenas-guerrero-julian commented 3 years ago
rr:predicateObjectMap [
      rr:objectMap [
          rr:column "YYYY";
          rr:termType rr:IRI
        ];
      rr:predicate :ex
    ];

The above mapping fails. I think because the engine does not allow to have rr:column with rr:termType rr:IRI

chrdebru commented 3 years ago

The mapping fails and returns an error code if the resulting value does not yield a valid, absolute IRI. If the column "YYYY" contains years, then it will only yield an IRI if you have provided a base IRI (e.g., "http://example.org/foo#", then the values of YYYY will be appended to the base IRI. If that's not the case, however, you will indeed get an error that it did not produce absolute IRIs.

chrdebru commented 3 years ago

Bear in mind that the base-IRI of the mapping is not the same as the base IRI that can be passed as input to the R2RML engine:

An R2RML processor also has access to an execution environment consisting of: A SQL connection to the input database, a base IRI used in resolving relative IRIs produced by the R2RML mapping.

arenas-guerrero-julian commented 3 years ago

I see, but if the column YYYY has values that are absolute & valid IRIs, it still fails right? but that should be correct

chrdebru commented 3 years ago

If the term map does not have a rr:termType property, then its term type is: rr:Literal, if it is an object map and at least one of the following conditions is true:

  • It is a column-based term map.
  • It has a rr:language property (and thus a specified language tag).
  • It has a rr:datatype property (and thus a specified datatype). rr:IRI, otherwise.

If you do not provide an rr:termType IRI, then it defaults to plain literals. If you provide an rr:termType IRI, then it will try to "parse" the values of the column YYYY as absolute valid IRIs. The engine will report an error code if that is not the case.

arenas-guerrero-julian commented 3 years ago

The problem here is that if I remove the rr:termType rr:IRI fro the example mapping it works, if I add it the engine fails at parsing the mapping.

chrdebru commented 3 years ago

Would you have a minimal example?

arenas-guerrero-julian commented 3 years ago

Mapping from GTFS-Madrid-Bench:

    rr:predicateObjectMap [
        rr:predicateMap [ rr:constant <http://vocab.gtfs.org/terms#routeUrl> ];
        rr:objectMap[
            rr:column "ROUTE_URL";
            rr:termType <http://www.w3.org/ns/r2rml#IRI>;
        ];
    ];

It fails, but if I remove the rr:termType <http://www.w3.org/ns/r2rml#IRI>;it works:

    rr:predicateObjectMap [
        rr:predicateMap [ rr:constant <http://vocab.gtfs.org/terms#routeUrl> ];
        rr:objectMap[
            rr:column "ROUTE_URL";
        ];
    ];
chrdebru commented 3 years ago

Here's my test:

data:

EMPNO,URI
7369,http://foo.bar

Mapping:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix ex: <http://example.com/ns#> .

<#TriplesMap1>
    rr:logicalTable [ rr:tableName "EMP" ] ;
    rr:subjectMap [
        rr:template "http://data.example.com/employee/{EMPNO}" ;
        rr:class ex:Employee ;
    ] ;
    rr:predicateObjectMap [
        rr:predicate ex:urlAsLiteralDefaultBehavior ;
        rr:objectMap [ rr:column "URI" ] ;
    ] ;
    rr:predicateObjectMap [
        rr:predicate ex:urlasIRI ;
        rr:objectMap [ rr:column "URI" ; rr:termType rr:IRI ] ;
    ]
.

Result:

@prefix rr:    <http://www.w3.org/ns/r2rml#> .
@prefix ex:    <http://example.com/ns#> .

<http://data.example.com/employee/7369>
        a                               ex:Employee ;
        ex:urlAsLiteralDefaultBehavior  "http://foo.bar" ;
        ex:urlasIRI                     <http://foo.bar> .

So, can you show me what the values of ROUTE_URL are?

arenas-guerrero-julian commented 3 years ago

@jatoledo can you take a look at this please?

chrdebru commented 3 years ago

Can you provide a minimal dataset reproducing the issue?

jatoledo commented 3 years ago

Hi @chrdebru. The problem was that the data in the column had been saved as a string("0000000oh") and did not represent a valid URI(as we put it in the mapping). You can close the issue. Thank you ;-)

chrdebru commented 3 years ago

Glad to hear it wasn't on my end! Thanks.