Closed c-martinez closed 5 years ago
Hello @c-martinez, I agree that the next step is extracting the transforming capabilities of the module. I received different suggestions on this topic and I will soon study the problem and produce the best solution.
Hi @pasqLisena -- great! Let us know if you have any suggestions or other recommendations for the grlc implementation.
Hey @pasqLisena, I'm implementing the new functionality as discussed above, with some simplifications. More specifically, I was trying to project results from this query:
SELECT ?p ?o WHERE
{
?_s ?p ?o
} LIMIT 5
into something like this:
{
"p1":"o1",
"p2":"o2",
"p3":"o3",
"p4":"o4",
"p5":"o5"
}
However, it looks like SPARQLTransformer
always returns a list? It also looks like it must always have an id
-- is that correct? What is the reasoning behind it?
However, it looks like SPARQLTransformer always returns a list?
Normally yes.
It also looks like it must always have an id -- is that correct? What is the reasoning behind it?
Yes, the id is an anchor for merging. For now, it is hardcoded, planning to make it selectable.
Back to your template, I am surprised that you don't want something like :
[
{"p1" : "o1"},
{"p2" : "o2"},
{"p3" : "o3"},
{"p4" : "o4"},
{"p5" : "o5"}
]
Anyway, for now, SPARQL Transformer is capable to output something like:
[
{"p" : "p1",
"o" : "o1" },
{"p" : "p2",
"o" : "o2" },
...
]
in other words, only the attribute values are replaced, while attribute names are not touched.
Ok, that kind of makes sense. And what would be the correct syntax for such a projection? I imagine I should use something like this (given that the id
is required at the moment):
{
"id": "?p",
"value": "?o"
}
Would give me something like:
[
{ "id" : "p1", "value" : "o1" },
{ "id" : "p2", "value" : "o2" },
...
]
Is that correct?
Exactly
Hi @c-martinez, I just released a version of ST in which you can replace that hard-coded id
with any other property with a $anchor
modifier. See documentation
Hi @pasqLisena. Nice! So this means I should be able to write something like this:
{
"key": "?p$anchor",
"value": "?o"
}
and get the desired result. Correct?
The proposal is merge the functionality of SPARQLtransform and projections (pyql files). We would prefer for queries to always be expressed as SPARQL, in order not to loose any of the SPARQL expressiveness, but to keep the transform result representation capability -- results from queries expressed as json. The transform syntax could be included using the
transform
keyword.The
.rq
file would look like this:@pasqLisena -- I discussed this with @albertmeronyo and we agreed this might be the best way forward. Do you have any comments / suggestions?