Binding sets of variables when calling sparql update stored query

Hi,

I would like to know how I could bind sets of variables when calling a SPARQL UPDATE stored query, instead of binding each variable separatly?

I have searched for a syntax supporting that in both the CLI and the HTTP API documentations. And I haven't find what I am looking for. There is only something about how to bind multiple values for one variable at a time, by separating the values with a blank. But this is not my use case as the values of a set need to be associated together.

In other words, I would like to provide the SPARQL UPDATE the parameters like I would use the VALUES clause as following:

values(?par1 ?par2 ?par3) { ("val1-1" "val2-1" "val3-1") ("val1-2" "val2-2" "val3-2") ... ("val1-n" "val2-n" "val3-n") }

I would have between 1 and 10 sets and not more. It is not a case of bulk load but transactional. But I would like to avoid multiple calls to Stardog from the application to improve the response time.

Thanks
Daniel

Daniel,

Neither Stardog nor the SPARQL Update spec facilitate this. As an alternative, you could add the bindings to a temporary named graph, join in your UPDATE and then drop the temporary graph.

Jess

1 Like

Thanks Jess for your clear answer.

I will try to group the parameters, that need to be together, in a single variable separated with some special characters (3 or more pipes for example). I will only need to extract each parameter in the stored query. And that should do the job.

Regards
Daniel

Can you use the UNNEST function in an update query? It's not standard but might work.

I was also curious if you can use the UNNEST function in an SMS2 mapping. I have a tsv file that has some comma separated fields. (There's a names column with multiple names steve,jill,toby, etc). I was preprocessing it with a python script and then thought, "maybe I can do this with SMS2 if I can use the UNNEST function. Unfortunately that's not the only problem, the file is a mess, so I'll have to stick with python but I was still wondering if you can use that function.

All functions can be used with file imports (CSV/JSON). The only problem here is that UNNEST is a SPARQL operator and not a function. :slight_smile: We are aware of the utility here and are keeping in mind the possibility as we evolve our data loading faciltities.

Jess

I faced similar limitation of unable to pass list/array of string as a parameter to a stored query.

As a temporary workaround I add a comment as a place holder and replace it in java code with actual

select *

where {

#TO_REPLACE#

?s ?p ?o

}

In java code replace #TO_REPLACE# with

values(?o) { "val1" "val2" “val3" }

I really wish a way to bind list/set/array of things to a query.

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