# R2rml mapping in Stardog Studio or converter

**URL:** <https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087>\
**Category:** Support\
**Created:** [November 13, 2022, 5:19pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087 "2022-11-13T17:19:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![horvatha](https://avatars.discourse-cdn.com/v4/letter/h/ac8455/32.png) [@horvatha](https://community.stardog.com/u/horvatha)\
**Post date:** [November 13, 2022, 5:19pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/1 "2022-11-13T17:19:21Z")

</div>

Hi!

Since I use protege/ontop to define mappings, I have an r2rml file for my postgres database, which I wanted to use in Stardog Studio to no avail, since it only accepts SMS2. Is there a way import an r2rml file to a database in a Stardog Free account, or to convert an r2rml file to SMS2?

Thank you in advance!

Best regards,

Attila Horváth

---

<div class="post-metadata">

**Author:** ![shane.blake](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@shane.blake](https://community.stardog.com/u/shane.blake)\
**Post date:** [November 13, 2022, 11:16pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/2 "2022-11-13T23:16:45Z")

</div>

Hi. You can use R2RML files for import. In Studio, create you PostgreSQL data source, then use the stardog-admin CLI to create the virtual graph. This is off the top of my head but it's something like (check the docs)

stardog-admin virtual add --format R2RML [graph name].properties [R2RML file].ttl

---

<div class="post-metadata">

**Author:** ![horvatha](https://avatars.discourse-cdn.com/v4/letter/h/ac8455/32.png) [@horvatha](https://community.stardog.com/u/horvatha)\
**Post date:** [November 14, 2022, 8:51am UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/3 "2022-11-14T08:51:12Z")

</div>

Thank you very much, I did not know that I could use the CLI on other than the local install 🙂 I did as you suggested, and got a funny error message:

Expected ], found '©' [L26]

although there is no such character in the mapping .ttl file.

This is the command I entered:

stardog-admin --server [https://sd-f0b3808c.stardog.cloud:5820](https://sd-f0b3808c.stardog.cloud:5820) virtual add -d stif -f r2rml -n vkg -s aws mbh\_mini\_ontologia\_prov\_101-mapping.ttl

If I leave out the mapping file from the command, then Stardog creates the virtual graph no problem. The "-v" option did not really give any meaningful addition to the error message. Is there a way to somehow get to the bottom of this, because I don't really get what the problem is.

Thank you in advance if you can help me out here!

---

<div class="post-metadata">

**Author:** ![horvatha](https://avatars.discourse-cdn.com/v4/letter/h/ac8455/32.png) [@horvatha](https://community.stardog.com/u/horvatha)\
**Post date:** [November 14, 2022, 8:56am UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/4 "2022-11-14T08:56:10Z")

</div>

Oh, I just found the solution, Stardog just doesn't like accented characters in IRIs, so removing an "é" just did the trick!

Thank you once again!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [December 6, 2022, 11:16pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/5 "2022-12-06T23:16:39Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [December 31, 2022, 3:39pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/6 "2022-12-31T15:39:54Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [January 28, 2023, 2:35am UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/7 "2023-01-28T02:35:33Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [February 24, 2023, 9:22pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/8 "2023-02-24T21:22:40Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [March 25, 2023, 8:43am UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/9 "2023-03-25T08:43:48Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [April 23, 2023, 8:07pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/10 "2023-04-23T20:07:46Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [May 24, 2023, 3:13pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/11 "2023-05-24T15:13:28Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [June 26, 2023, 4:09am UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/12 "2023-06-26T04:09:22Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [July 29, 2023, 4:17pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/13 "2023-07-29T16:17:01Z")

</div>



---

<div class="post-metadata">

**Author:** ![mike\_res](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@mike\_res](https://community.stardog.com/u/mike_res)\
**Post date:** [July 29, 2023, 8:42pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/14 "2023-07-29T20:42:30Z")

</div>

I literally saw this post when I was going to post on a similar matter!

Much like @horvatha .. I started out using protege/ontop, and I migrated the VKG to Stardog by exporting the Ontop mappings as R2RML, and then importing them into Stardog.

As an aside .. the import process took a very long time .. like maybe 30 minutes-ish? I know for sure it was well over 20 minutes. The VKG in question has 530 tables, and there are several mapped fields for each table -- so maybe this is to be expected.

In any case, here's a quick summary of the tweaks I had to make to my R2RML, in case it helps others:

- **I was unable to import the R2RML using the VKG creation process in the UI.**
  - **My impression is that the UI will only accept SMS2 format for the mappings file** , but I'm uncertain of that, because it turned out that my R2RML file had some issues (details below).

- **The** _`stardog-admin virtual add `_ **command quits quietly if there is a problem.** I could probably have gotten diagnostics by looking in the log, but I decided instead to turn on the `-v` (verbose) option when importing,

```auto
stardog-admin virtual add -v --format r2rml --name my_vkg_using_r2rml --data-source my_data_source my_r2rml.ttl

```

- **It turns out that trailing ";" characters in SQL statements are unwelcome**. In other words, something like this fails:

```auto
  rr:logicalTable [ a rr:R2RMLView;
      rr:sqlQuery "SELECT id, field_a, field_b, field_c FROM some_schema.some_table; 
    ];

```

But removing the trailing ";" makes the r2rml import happy:

```auto
  rr:logicalTable [ a rr:R2RMLView;
      rr:sqlQuery "SELECT id, field_a, field_b, field_c FROM some_schema.some_table
    ];

```

- **Certain field names cause problems**. I had to rename certain fields. Although postgres was hppy to accept these field names, as long as they were quoted, using their unquoted form as the object of an `rr:column` predicate caused an error.
  - **Here is a list of the "problematic field names" that I encountered**. It's unlikely to be complete.

  - **I dealt with the issue by renaming the fields in question.** Here is an R2RML fragment (hopefully syntactically correct) for mapping a table whose columns consist solely of problematic names.

```auto
<urn:get_crazy_class> a rr:TriplesMap;
  rr:logicalTable [ a rr:R2RMLView;
      rr:sqlQuery "\"condition\" as condition_, \"date\" as date_, \"day\" as day_, \"empty\" as empty_, \"full\" as full_, \"method\" as method_, \"result\" as result_, \"time\" as time_, \"timestamp\" as timestamp_ from some_schema.crazy_table"
    ];
  rr:predicateObjectMap [ a rr:PredicateObjectMap;
      rr:objectMap [ a rr:ObjectMap, rr:TermMap;
          rr:column "condition_";
          rr:termType rr:Literal
        ];
      rr:predicate <http://example.com#data#condition>
    ], [ a rr:PredicateObjectMap;
      rr:objectMap [ a rr:ObjectMap, rr:TermMap;
          rr:column "date_";
          rr:termType rr:Literal
        ];
      rr:predicate <http://example.com/data#date>
    ], [ a rr:PredicateObjectMap;
      rr:objectMap [ a rr:ObjectMap, rr:TermMap;
          rr:column "day_";
          rr:termType rr:Literal
        ];
      rr:predicate <http://example.com/data#day>
    ], [ a rr:PredicateObjectMap;
      rr:objectMap [ a rr:ObjectMap, rr:TermMap;
          rr:column "empty_";
          rr:termType rr:Literal
        ];
      rr:predicate <http://example.com/data#empty>
    ], [ a rr:PredicateObjectMap;
      rr:objectMap [ a rr:ObjectMap, rr:TermMap;
          rr:column "full_";
          rr:termType rr:Literal
        ];
      rr:predicate <http://example.com/data#full>
    ], [ a rr:PredicateObjectMap;
      rr:objectMap [ a rr:ObjectMap, rr:TermMap;
          rr:column "method_";
          rr:termType rr:Literal
        ];
      rr:predicate <http://example.com/data#method>
    ], [ a rr:PredicateObjectMap;
      rr:objectMap [ a rr:ObjectMap, rr:TermMap;
          rr:column "result_";
          rr:termType rr:Literal
        ];
      rr:predicate <http://example.com/data#result>
    ], [ a rr:PredicateObjectMap;
      rr:objectMap [ a rr:ObjectMap, rr:TermMap;
          rr:column "time_";
          rr:termType rr:Literal
        ];
      rr:predicate <http://example.com/data#time>
    ], [ a rr:PredicateObjectMap;
      rr:objectMap [ a rr:ObjectMap, rr:TermMap;
          rr:column "timestamp_";
          rr:termType rr:Literal
        ];
      rr:predicate <http://example.com/data#timestamp>
    ];
  rr:subjectMap [ a rr:SubjectMap, rr:TermMap;
      rr:class :crazy_class;
      rr:template "http://example.com/{id}";
      rr:termType rr:IRI
    ] .

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [September 3, 2023, 11:00pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/15 "2023-09-03T23:00:29Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [October 16, 2023, 2:53pm UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/16 "2023-10-16T14:53:30Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [December 3, 2023, 12:22am UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/17 "2023-12-03T00:22:23Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [January 23, 2024, 10:48am UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/18 "2024-01-23T10:48:44Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [March 19, 2024, 7:36am UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/19 "2024-03-19T07:36:10Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [May 23, 2024, 6:05am UTC](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087/20 "2024-05-23T06:05:27Z")

</div>



[Next page](https://community.stardog.com/t/r2rml-mapping-in-stardog-studio-or-converter/4087.md?page=2)
