You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Laurent Pellegrino <la...@gmail.com> on 2011/11/02 10:54:50 UTC

STRSTARTS does not work with Transactional TDB

Hi all,

I have executing a SPARQL Select query which filters quadruples
according to a prefix in the graph value. The SPARQL query is the
following:

SELECT ?g ?s ?p ?o WHERE {
    GRAPH ?g {
        ?s ?p ?o .
        FILTER (STRSTARTS(str(?g), "https://plus.google.com/825349613"))
    }
}

It seems that the query works when it is executed with a basic Dataset
but when it is executed with a transactional Dataset it does not work.
Hereafter are the links to the tests (I use the last snapshots from
the apache repository):

1/ This is the test associated to the basic Dataset where the query works:
http://pastebin.com/raw.php?i=Atkt16Zk

the output is, as expected:

> TestDatasetGraph.main() results are:
>   https://plus.google.com/825349613/$1320226073388/$null

2/ The test which is not working (returns no result) and that uses a
transactional dataset:

http://pastebin.com/raw.php?i=vcCJV30P

Do I miss something in the second test or is it a bug?

Kind Regards,
Laurent

Re: STRSTARTS does not work with Transactional TDB

Posted by Andy Seaborne <an...@apache.org>.
A fix for JENA-154 (JIRA for this issue) has gone into SVN.

The probelm was a design flaw, so there is a new way to convert 
GRAPH/triples to quads as well as a new way to execution GRAPH/triples.

Downside is that it is an application-visible change.  Many common-case 
queries already correctly written will yield the same answers but not 
all of them.  Putting the filter inside the GRAPH will change - it was 
acting as if outside for {} block.

It is now SPARQL-compliant though.

	Andy




On 03/11/11 09:28, Laurent Pellegrino wrote:
>> Does plain TDB, without using the transaction interface work at all?
>
> No, it does not work. As you said, it affects all TDB datasets.
>
>> (I guess that plain TDB will behave like TxTDB and that it's to do with the
>> process of truning into quads)
>>
>> I've opened JENA-154 for this.
>>
>> I'll start by fixing ARQ to correctly handle patterns inside GRAPH ?g {}
>> that define or mention the outer ?g.
>>
>>         Andy


Re: STRSTARTS does not work with Transactional TDB

Posted by Laurent Pellegrino <la...@gmail.com>.
> Does plain TDB, without using the transaction interface work at all?

No, it does not work. As you said, it affects all TDB datasets.

> (I guess that plain TDB will behave like TxTDB and that it's to do with the
> process of truning into quads)
>
> I've opened JENA-154 for this.
>
> I'll start by fixing ARQ to correctly handle patterns inside GRAPH ?g {}
> that define or mention the outer ?g.
>
>        Andy

Re: STRSTARTS does not work with Transactional TDB

Posted by Andy Seaborne <an...@apache.org>.
On 02/11/11 15:14, Laurent Pellegrino wrote:
> Thanks Andy for your help. I have understood the problem of scope but
> even if I move the FILTER clause outside the GRAPH block I stil get no
> result with the transactional TDB dataset.
>
>      Laurent
>

Does plain TDB, without using the transaction interface work at all?

(I guess that plain TDB will behave like TxTDB and that it's to do with 
the process of truning into quads)

I've opened JENA-154 for this.

I'll start by fixing ARQ to correctly handle patterns inside GRAPH ?g {} 
that define or mention the outer ?g.

	Andy

Re: STRSTARTS does not work with Transactional TDB

Posted by Laurent Pellegrino <la...@gmail.com>.
Thanks Andy for your help. I have understood the problem of scope but
even if I move the FILTER clause outside the GRAPH block I stil get no
result with the transactional TDB dataset.

    Laurent

On Wed, Nov 2, 2011 at 3:22 PM, Andy Seaborne <an...@apache.org> wrote:
> Hi Laurent,
>
> There is a bug ...
>
> .. it's nothing to do with transactions
> (try http://pastebin.com/LzDFqf0g for using with plain TDB and plain ARQ
>
> ... it's nothing to do with STRSTARTS
>
> ... it's every thing to do with the scope of ?g
>
> The problem is the scope of ?g - it should only come into visibility when
> GRAPH ?g happens -
>
> In { ?s ?p ?o  FILTER ( ... ?g ... ) }
> then ?g is not bound so the filter is false.
>
> TDB is right (but I'm not sure why) - it's ARQ that's wrong!
>
>
> You possibly meant:
>
>  SELECT ?g ?s ?p ?o WHERE {
>      GRAPH ?g {
>          ?s ?p ?o .
>      }
>      FILTER (STRSTARTS(str(?g), "https://plus.google.com825349613"))
>  }
>
> i.e the FILTER outside the GRAPH block, after ?g is set and in-scope.
>
> Time to go and think ...
>
> Thank you for the report
>
>        Andy
>
> On 02/11/11 09:54, Laurent Pellegrino wrote:
>>
>> Hi all,
>>
>> I have executing a SPARQL Select query which filters quadruples
>> according to a prefix in the graph value. The SPARQL query is the
>> following:
>>
>> SELECT ?g ?s ?p ?o WHERE {
>>     GRAPH ?g {
>>         ?s ?p ?o .
>>         FILTER (STRSTARTS(str(?g), "https://plus.google.com/825349613"))
>>     }
>> }
>>
>> It seems that the query works when it is executed with a basic Dataset
>> but when it is executed with a transactional Dataset it does not work.
>> Hereafter are the links to the tests (I use the last snapshots from
>> the apache repository):
>>
>> 1/ This is the test associated to the basic Dataset where the query works:
>> http://pastebin.com/raw.php?i=Atkt16Zk
>>
>> the output is, as expected:
>>
>>> TestDatasetGraph.main() results are:
>>>   https://plus.google.com/825349613/$1320226073388/$null
>>
>> 2/ The test which is not working (returns no result) and that uses a
>> transactional dataset:
>>
>> http://pastebin.com/raw.php?i=vcCJV30P
>>
>> Do I miss something in the second test or is it a bug?
>>
>> Kind Regards,
>> Laurent
>
>

Re: STRSTARTS does not work with Transactional TDB

Posted by Andy Seaborne <an...@apache.org>.
Hi Laurent,

There is a bug ...

.. it's nothing to do with transactions
(try http://pastebin.com/LzDFqf0g for using with plain TDB and plain ARQ

... it's nothing to do with STRSTARTS

... it's every thing to do with the scope of ?g

The problem is the scope of ?g - it should only come into visibility 
when GRAPH ?g happens -

In { ?s ?p ?o  FILTER ( ... ?g ... ) }
then ?g is not bound so the filter is false.

TDB is right (but I'm not sure why) - it's ARQ that's wrong!


You possibly meant:

  SELECT ?g ?s ?p ?o WHERE {
       GRAPH ?g {
           ?s ?p ?o .
       }
       FILTER (STRSTARTS(str(?g), "https://plus.google.com825349613"))
  }

i.e the FILTER outside the GRAPH block, after ?g is set and in-scope.

Time to go and think ...

Thank you for the report

	Andy

On 02/11/11 09:54, Laurent Pellegrino wrote:
> Hi all,
>
> I have executing a SPARQL Select query which filters quadruples
> according to a prefix in the graph value. The SPARQL query is the
> following:
>
> SELECT ?g ?s ?p ?o WHERE {
>      GRAPH ?g {
>          ?s ?p ?o .
>          FILTER (STRSTARTS(str(?g), "https://plus.google.com/825349613"))
>      }
> }
>
> It seems that the query works when it is executed with a basic Dataset
> but when it is executed with a transactional Dataset it does not work.
> Hereafter are the links to the tests (I use the last snapshots from
> the apache repository):
>
> 1/ This is the test associated to the basic Dataset where the query works:
> http://pastebin.com/raw.php?i=Atkt16Zk
>
> the output is, as expected:
>
>> TestDatasetGraph.main() results are:
>>    https://plus.google.com/825349613/$1320226073388/$null
>
> 2/ The test which is not working (returns no result) and that uses a
> transactional dataset:
>
> http://pastebin.com/raw.php?i=vcCJV30P
>
> Do I miss something in the second test or is it a bug?
>
> Kind Regards,
> Laurent