On 04/03/15 18:23, trylks wrote:
I am processing a SPARQL query with Jena ARQ, version 2.12.1 (the latest I
found on maven central repository). For this I perform
Algebra.compile(QueryFactory.read(__theQuery__)) and I navigate through the
structure until I get to a OpProject.
I would like to obtain the real name of the variables in the head of the
query, not the aliases. Alternatively a binding among them (variables and
aliases) should suffice.
I understand this information is present at OpProject.getVars.
That method returns the variables, however both Var.getName and
Var.getVarName methods return the alias of the variable, not the original
name.
I don't quite follow here -
In
SELECT (?x as ?y)
you want (from the algebra) "x" not "y"
project will say "y" because all the project operator can do is let
through or hide a variable.
"SELECT (?x as ?y)" is a combination of algerba operations, an "extend"
(BIND) and the project.
So ...
You need to look in all the places that varibales can be bound - there
aren't too many:
Basic graph patterns
assignments (extend)
GRAPH
Aggregates (variables like ?.0 for the group value)
and there are renames where ARQ hides a variable by renaming it in the
form "?/var"
There may not be an original variable
SELECT (1+2 as ?y)
BIND (1+2 as ?y)
because the assignment is an expression to a variable.
Do you have a concrete example (algebra expression or query) and the
variables you want to get out, that we can discuss?
Andy
I understand it would be possible to obtain the original name of the
variable having the binding, according to the method Var.lookup, however I
was not able to obtain such a binding from anywhere.
I could not find information in the documentation for this specific matter.
Thank you for your help.
Referenced classes:
com.hp.hpl.jena.sparql.algebra.op.OpProject
com.hp.hpl.jena.query.QueryFactory
com.hp.hpl.jena.sparql.algebra.Algebra
com.hp.hpl.jena.sparql.core.Var