RMLStreamer Function grel:array_join produces inconsistent results

121 views Asked by At

In RMLStreamer, grel:arra_join function does not produce the expected results.

Mapping File (mapping.ttl)

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix grel:     <http://users.ugent.be/~bjdmeest/function/grel.ttl#> .
@prefix idlab-fn: <http://example.com/idlab/function/> .
@prefix fno:      <https://w3id.org/function/ontology#> .
@prefix gist: <http://ontologies.semanticarts.com/gist#>.
@prefix fnml: <http://semweb.mmlab.be/ns/fnml#> .
@base <http://example.com/base/> .

<TriplesMap1> a rr:TriplesMap;
              rml:logicalSource [
                                    rml:source "student.csv";
                                    rml:referenceFormulation ql:CSV
                                ];
              rr:subjectMap [
                                rr:template "http://example.com/{ID}/{Name}";
                                rr:class foaf:Person
                            ];
              rr:predicateObjectMap [
                                        rr:predicate ex:id ;
                                        rr:objectMap [ rml:reference "ID" ]
                                    ];
              rr:predicateObjectMap [
                                        rr:predicate gist:end;
                                        rr:objectMap <#FunctionMapDateTimeEnd>
                                    ].

<#FunctionMapDateTimeEnd> a fnml:FunctionTermMap;
                          rr:datatype  xsd:dateTime;
                          fnml:functionValue [
                                         rml:logicalSource "student.csv";
                                         rr:predicateObjectMap [
                                                 rr:predicate fno:executes;
                                                 rr:objectMap [ rr:constant grel:array_join ] ;
                                                               ] ;
                                         rr:predicateObjectMap [
                                                 rr:predicate grel:p_array_a ;
                                                 rr:objectMap [ rml:reference "date" ] ;
                                                                ] ;
                                         rr:predicateObjectMap [
                                                rr:predicate grel:p_array_a ;
                                                rr:objectMap [ rr:constant "T12:00:00.000Z"; ] ;
                                                               ] ;
                                             ].

student.csv

ID,Name,Comment,Class,date
1,Venus,A&B,A,2019-11-01

Output

<http://example.com/1/Venus> <http://ontologies.semanticarts.com/gist#end> "T12:00:00.000Z2019-11-01"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://example.com/1/Venus> <http://example.com/id> "1" .
<http://example.com/1/Venus> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .

The problem with the output is the order of join by grel:array_join. Executing the same files multiple times generate different results.

<http://example.com/1/Venus> <http://ontologies.semanticarts.com/gist#end> "T12:00:00.000Z2019-11-01"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://example.com/1/Venus> <http://ontologies.semanticarts.com/gist#end> "2019-11-01T12:00:00.000Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .

However, the expected output is to join the list in the given order (2019-11-01T12:00:00.000Z) every time.

The same mapping file with RMLMapper produces consistent and correct results and join the list in the given order.

Other functions such as grel:toUpperCase and idlab-fn:toUpperCaseURL work fine and produce correct results in both RMLStreamer and RMLMapper

1

There are 1 answers

1
Thomas Delva On

To solve your specific issue, have you tried replacing <#FunctionMapDateTimeEnd> with a template-valued term map with template "{date}T12:00:00.000Z"? Alternatively, you could link your own function to concatenate two strings. If that function uses named parameters, their order is preserved by default.

More generally, there are indeed some known issues with preserving order in RML+FnO array parameters, although there is also work to fix them, see for example this issue and the related community group page.