Skip to content

Add example mixing use of rml-views and gather maps #30

Open

Description

@frmichel

This example should be added only when the fields specification is released.
Anyway, the issue does not prevent from releasing a first version of the specification.

See existing example: #10 (comment)

Activity

  1. added
    pendingIssue is pending due e.g. to a dependency with another or only applicable to a further release
    documentationImprovements or additions to documentation
    on Jan 18, 2023
  2. frmichel commented on Sep 11, 2023

    @frmichel
    CollaboratorAuthor

    @dachafra @chrdebru @andimou : To finalize this example I need the spec of the Fields (rml:field... ) but I fail to find it... Shouldn't it be in rml-io? Did i miss something?

  3. dachafra commented on Sep 11, 2023

    @dachafra
    Member

    Fields is still in discussion. Indeed, in the joins task force, we are going to present the solution again and see if it covers all the requirements that we need. In any case, the issues that are labeled with pending do not need to be fixed now, as others need to be resolved before (as in this one)!

  4. frmichel commented on Dec 15, 2023

    @frmichel
    CollaboratorAuthor

    This question was discussed during the meeting in Santiago de Compostela. Here is the solution that was agreed:
    @dachafra @chrdebru @andimou @bjdmeest @pmaria: could you please confirm that we understood the same thing?

    Input document "source.json":

    { 
      "id": 1,
      "a" : [ [1,2,3], [4,5,6] ]
    }

    The expected output is to generate a list of lists, where the head node of the outer list has a URI:

    <http://my.list/1>
      rdf:first (1 2 3);
      rdf:rest [ 
        rdf:first (4 5 6);
        rdf:rest rdf:nil 
      ].
    

    The solution involves a logical source for the json file, and a logical view that declares fields:

    <LS> 
        a rml:LogicalSource ;
        rml:source "source.json" ;
        rml:referenceFormulation ql:JSONPath;
    ].
    
    <LV>
        a rml:LogicalView ;
        rml:logicalSource <LS> ;
        rml:field [ 
          rml:fieldName "id" ;
          rml:reference "$.id" ;
        ] ;
        rml:field [ 
          rml:fieldName "a_string" ;
          rml:reference "$.a.*" ;
          rml:field [ 
            rml:fieldName "a_list" ;
            # Reference "$.*" applies to the results produced by evaluating "$.a.*"
            rml:reference "$.*" ;
            rml:groupBy "a"
          ]
        ]
    ].

    This reshapes the input document into a table with 2 lines:

    id a_string a_list
    1 [1,2,3] 1,2,3
    1 [4,5,6] 4,5,6

    Here, a_string is a string representation of the json array: "[1,2,3]", "[4,5,6]", so not really usable unless it would be parsed by a function for instance.
    Conversely, a_list is built by parsing the json arrays returned by "$.a.*", so it is an enumeration of the terms 1, 2, 3, and 4, 5, 6.
    The datatype of that list field has not been specified yet and requires further discussions.

    Now applying the following term map should generate the expected result:

    rr:subjectMap [ 
      rr:template "http://my.list/{id}";
      rml:gather ( [ 
        rml:gather ( [
          # "a_list" is multi-valued, it evaluates to the 3 terms  in each arrays: first iteration: 1, 2, 3, then 4, 5, 6.
          rml:reference "a_list" ;
          rml:gatherAs rdf:List;
        ] )
      ] );
      rml:gatherAs rdf:List;
    ] ;
  5. pmaria commented on Dec 17, 2023

    @pmaria

    Hi @frmichel,

    Indeed! Only the object of the rml:groupBy statement would be a_string, but I think that was your intention.

    So the logical view would be defined as such:

    <LV>
        a rml:LogicalView ;
        rml:logicalSource <LS> ;
        rml:field [ 
          rml:fieldName "id" ;
          rml:reference "$.id" ;
        ] ;
        rml:field [ 
          rml:fieldName "a_string" ;
          rml:reference "$.a.*" ;
          rml:field [ 
            rml:fieldName "a_list" ;
            # Reference "$.*" applies to the results produced by evaluating "$.a.*"
            rml:reference "$.*" ;
            rml:groupBy "a_string"
          ]
        ]
    ].
  6. frmichel commented on Dec 17, 2023

    @frmichel
    CollaboratorAuthor

    Yes you're right, sorry for the typo. I renamed a and a2 into a_string and a_list for clarification, but I forgot to change a in groupBy ;).

  7. added and removed
    pendingIssue is pending due e.g. to a dependency with another or only applicable to a further release
    on Dec 20, 2023
  8. dachafra commented on Dec 20, 2023

    @dachafra
    Member

    Ok for me, I've also changed the label from pending to proposal

  9. changed the title [-]Add example mixing use of fields and gather maps[/-] [+]Add example mixing use of rml-views and gather maps[/+] on Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationproposal

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions