+1 to Paul.

You can turn on global strict mode and it won't overload ?x + ?y in this way. You'll get an error and so ?sum is undefined.

You can't set strict mode on expression evauation per execution. The expression evaluator does not know the context.

There is never an implicit cast. The lack of type information makes that impossible in general. The other issue is casting is locale sensitive. 10,001 is what?

        Andy

On 21/04/14 20:22, Paul Gearon wrote:
This is an ARQ extension to SPARQL. The expression (?x + ?y AS ?sum) is
only defined for numbers, meaning that it is undefined for string values,
even if they can be converted. If a result is "undefined" then it can be
returned as anything.

Someone thought that it would be a good idea to have + duplicate the concat
operation when applied to strings.

To explore further, section 17.5 points out that if a simple literal (which
is now of type xsd:string) has a lexical value that is compatible with a
target type, then a cast may be made:
http://www.w3.org/TR/sparql11-query/#FunctionMapping

Since the + operator is only defined for numbers, then it may seem
reasonable to assume that this an implicit cast should be performed for the
strings "1" and "2", leading to a result of 3. However, casting is only
defined to occur when explicitly requested, as in: (xsd:integer(?x) +
xsd:integer(?y) AS ?sum).

Regards,
Paul



On Mon, Apr 21, 2014 at 1:39 PM, Tim Harsch <harschw...@gmail.com> wrote:

Hi,
I've been trying to figure out an issue with addition of strings in
SPARQL.  According to the DAWG evaluation test at:
http://www.w3.org/2009/sparql/docs/tests/summary.html#functions-plus-1
"1" + "2" != "12", but ARQ run via Fuseki-1.0.1 would seem to disagree.  I
also tried running the following similar query on dbpedia
# :x6 :p "1" ; :q "2" .
SELECT ?x ?y ( ?x + ?y AS ?sum)
WHERE
{
   VALUES( ?x ?y ) {
        ( "1" "2" )
   }
}
ORDER BY ?x ?y ?sum

and it seems to agree with the W3C expected results.  Is this a bug in ARQ?

Thanks,
Tim



Reply via email to