Sms2 and blank nodes

Hi there,

Could you please help in understanding the sms syntax and whether it supports generating graphs with blank nodes? E.g., consider the following mapping:


    "client_id" : "?client_id",
    "transaction_id": "?transaction_id",
    "sum": "?sum",
    "time": "?time",
TO {
  ?client a :Client ;
    :hasTransactionInfo [
      :transaction ?transaction ;
      :timestamp ?dateTime ;
      :amount ?amount ;
    ] .
  bind(template("{client_id}") as ?client)
  bind(template("{transaction_id}") as ?transaction)
  bind(xsd:dateTime(?time) as ?dateTime)
  bind(xsd:integer(?sum) as ?amount)

with the input json document

  "client_id": "12345",
  "transaction_id": "abcdefg" ,
  "sum": 2000,
  "time": 1569266867591,  

After executing the command

stardog-admin virtual import testDB transactions.sms transactions.json

the only triple that is created in the database is

<> a :Client .

The issue seems to be that the TO clause does not allow generating blank nodes. Is that intentional? The documentation only says that it is analogous to the CONSTRUCT portion of the SPARQL CONSTRUCT query, but with CONSTRUCT one can generate such graphs.
Could anyone clarify that? Thanks!

Hi Evgeny,

To preface, using the bnode syntax in the TO (aka target) of the mapping is not currently supported. This is the reason you are seeing the result of only a single triple being generated (assuming there's only one object in your JSON file). Admittedly, we'll need to improve the parser here to raise an error rather than output an unexpected result.

In order to generate the requested structure, you will need to add a BIND with the BNODE function using something to identify the bnode, perhaps the transaction id. The reason for this is that the BNODE function would be called only once if there were no arguments and the same bnode value would be used in all generated triples. If we were to evaluate it for each triple generated, each pattern inside the square brackets would have a different subject. The mapping from JSON needs a indication of the "scope" of the bnode. If your transaction is unique for each client and transaction info, it will work perfectly here. We'll update the documentation to clarify this. Thanks for reaching out and let us know if this works and if you have any more questions.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.