You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Tim Harsch <ha...@yahoo.com> on 2011/05/06 21:31:11 UTC

query where distinct and minus have no effect

Hi,
Using the LUBM0 dataset I tried the following query in Fuseki-0.1.0.

PREFIX ub:    <http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#>
SELECT DISTINCT *
 WHERE { 
  ?n0 ub:teacherOf ?n1.
  MINUS { <http://www.Department0.University0.edu/AssistantProfessor0> 
ub:teacherOf <http://www.Department0.University0.edu/Course38> }
} ORDER BY ?n0 ?n1

The first three results are below.  Notice the first result contains 
AssistantProfessor0, Course38 (violating the MINUS) and the next two results are 
redundant (shouldn't happen with DISTINCT).  Any ideas?  The NT file can be 
found in this Zip archive I packed up for other reasons ( http://bit.ly/k8adNJ 
).


    <result>
      <binding name="n0">
        http://www.Department0.University0.edu/AssistantProfessor0
      </binding>
      <binding name="n1">
        http://www.Department0.University0.edu/Course38
      </binding>
    </result>
    <result>
      <binding name="n0">
        http://www.Department0.University0.edu/AssistantProfessor0
      </binding>
      <binding name="n1">
        http://www.Department0.University0.edu/Course39
      </binding>
    </result>
    <result>
      <binding name="n0">
        http://www.Department0.University0.edu/AssistantProfessor0
      </binding>
      <binding name="n1">
        http://www.Department0.University0.edu/GraduateCourse39
      </binding>
    </result>

Re: query where distinct and minus have no effect

Posted by Tim Harsch <ha...@yahoo.com>.
Hi Andy,
This seemed to work:
   MINUS { ?n0 ub:teacherOf <http://www.Department0.University0.edu/Course38> .
    <http://www.Department0.University0.edu/AssistantProfessor0> ub:teacherOf 
?n1 . }

The FILTER you came up with occurred to me, but the purpose of these queries 
with MINUS in them were for my own discovery with the MINUS construct.  That 
BIND() is bizarre but cool too :-)



________________________________
From: Andy Seaborne <an...@epimorphics.com>
To: jena-users@incubator.apache.org
Sent: Fri, May 6, 2011 2:58:10 PM
Subject: Re: query where distinct and minus have no effect



On 06/05/11 21:33, Damian Steer wrote:
> Hi Tim,
>
> Sorry, still on my phone so this is from memory: your MINUS doesn't bind 
>anything, so nothing will be removed. You could FILTER out that result?

Spot on.

FILTER NOT EXISTS might be what you want.

although still you need to binding something in right hand side.

or simply

FILTER(?n0 != 
<http://www.Department0.University0.edu/AssistantProfessor0> && ?n1 != 
<http://www.Department0.University0.edu/Course38> )

MINUS removes rows on the left depending on whether they they are 
compatible and share a common variable with rows on the right.

...
MINUS
{ BIND(<http://www.Department0.University0.edu/AssistantProfessor0> AS ?n0
   BIND(<http://www.Department0.University0.edu/Course38> AS ?n1)
}

is a quite bizarre way of doing it.

    Andy

>
> Damian
>
> Sent from my iPhone
>
> On 6 May 2011, at 20:42, Tim Harsch<ha...@yahoo.com>  wrote:
>
>> oops should have looked closer.   The DISTINCT is not violated.  Question
>> remains about MINUS.
>>
>>
>>
>>
>> ________________________________
>> From: Tim Harsch<ha...@yahoo.com>
>> To: JENA-USERS<je...@incubator.apache.org>
>> Sent: Fri, May 6, 2011 12:31:11 PM
>> Subject: query where distinct and minus have no effect
>>
>> Hi,
>> Using the LUBM0 dataset I tried the following query in Fuseki-0.1.0.
>>
>> PREFIX ub:<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#>
>> SELECT DISTINCT *
>> WHERE {
>>   ?n0 ub:teacherOf ?n1.
>>   MINUS {<http://www.Department0.University0.edu/AssistantProfessor0>
>> ub:teacherOf<http://www.Department0.University0.edu/Course38>  }
>> } ORDER BY ?n0 ?n1
>>
>> The first three results are below.  Notice the first result contains
>> AssistantProfessor0, Course38 (violating the MINUS) and the next two results 
>>are
>>
>> redundant (shouldn't happen with DISTINCT).  Any ideas?  The NT file can be
>> found in this Zip archive I packed up for other reasons ( 
http://bit.ly/k8adNJ
>> ).
>>
>>
>>     <result>
>>       <binding name="n0">
>>        http://www.Department0.University0.edu/AssistantProfessor0
>>       </binding>
>>       <binding name="n1">
>>        http://www.Department0.University0.edu/Course38
>>       </binding>
>>     </result>
>>     <result>
>>       <binding name="n0">
>>        http://www.Department0.University0.edu/AssistantProfessor0
>>       </binding>
>>       <binding name="n1">
>>        http://www.Department0.University0.edu/Course39
>>       </binding>
>>     </result>
>>     <result>
>>       <binding name="n0">
>>        http://www.Department0.University0.edu/AssistantProfessor0
>>       </binding>
>>       <binding name="n1">
>>        http://www.Department0.University0.edu/GraduateCourse39
>>       </binding>
>>     </result>

Re: query where distinct and minus have no effect

Posted by Andy Seaborne <an...@epimorphics.com>.

On 06/05/11 21:33, Damian Steer wrote:
> Hi Tim,
>
> Sorry, still on my phone so this is from memory: your MINUS doesn't bind anything, so nothing will be removed. You could FILTER out that result?

Spot on.

FILTER NOT EXISTS might be what you want.

although still you need to binding something in right hand side.

or simply

FILTER(?n0 != 
<http://www.Department0.University0.edu/AssistantProfessor0> && ?n1 != 
<http://www.Department0.University0.edu/Course38> )

MINUS removes rows on the left depending on whether they they are 
compatible and share a common variable with rows on the right.

...
MINUS
{ BIND(<http://www.Department0.University0.edu/AssistantProfessor0> AS ?n0
   BIND(<http://www.Department0.University0.edu/Course38> AS ?n1)
}

is a quite bizarre way of doing it.

	Andy

>
> Damian
>
> Sent from my iPhone
>
> On 6 May 2011, at 20:42, Tim Harsch<ha...@yahoo.com>  wrote:
>
>> oops should have looked closer.   The DISTINCT is not violated.  Question
>> remains about MINUS.
>>
>>
>>
>>
>> ________________________________
>> From: Tim Harsch<ha...@yahoo.com>
>> To: JENA-USERS<je...@incubator.apache.org>
>> Sent: Fri, May 6, 2011 12:31:11 PM
>> Subject: query where distinct and minus have no effect
>>
>> Hi,
>> Using the LUBM0 dataset I tried the following query in Fuseki-0.1.0.
>>
>> PREFIX ub:<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#>
>> SELECT DISTINCT *
>> WHERE {
>>   ?n0 ub:teacherOf ?n1.
>>   MINUS {<http://www.Department0.University0.edu/AssistantProfessor0>
>> ub:teacherOf<http://www.Department0.University0.edu/Course38>  }
>> } ORDER BY ?n0 ?n1
>>
>> The first three results are below.  Notice the first result contains
>> AssistantProfessor0, Course38 (violating the MINUS) and the next two results are
>>
>> redundant (shouldn't happen with DISTINCT).  Any ideas?  The NT file can be
>> found in this Zip archive I packed up for other reasons ( http://bit.ly/k8adNJ
>> ).
>>
>>
>>     <result>
>>       <binding name="n0">
>>         http://www.Department0.University0.edu/AssistantProfessor0
>>       </binding>
>>       <binding name="n1">
>>         http://www.Department0.University0.edu/Course38
>>       </binding>
>>     </result>
>>     <result>
>>       <binding name="n0">
>>         http://www.Department0.University0.edu/AssistantProfessor0
>>       </binding>
>>       <binding name="n1">
>>         http://www.Department0.University0.edu/Course39
>>       </binding>
>>     </result>
>>     <result>
>>       <binding name="n0">
>>         http://www.Department0.University0.edu/AssistantProfessor0
>>       </binding>
>>       <binding name="n1">
>>         http://www.Department0.University0.edu/GraduateCourse39
>>       </binding>
>>     </result>

Re: query where distinct and minus have no effect

Posted by Damian Steer <d....@bristol.ac.uk>.
Hi Tim,

Sorry, still on my phone so this is from memory: your MINUS doesn't bind anything, so nothing will be removed. You could FILTER out that result?

Damian

Sent from my iPhone

On 6 May 2011, at 20:42, Tim Harsch <ha...@yahoo.com> wrote:

> oops should have looked closer.   The DISTINCT is not violated.  Question 
> remains about MINUS.
> 
> 
> 
> 
> ________________________________
> From: Tim Harsch <ha...@yahoo.com>
> To: JENA-USERS <je...@incubator.apache.org>
> Sent: Fri, May 6, 2011 12:31:11 PM
> Subject: query where distinct and minus have no effect
> 
> Hi,
> Using the LUBM0 dataset I tried the following query in Fuseki-0.1.0.
> 
> PREFIX ub:    <http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#>
> SELECT DISTINCT *
> WHERE { 
>  ?n0 ub:teacherOf ?n1.
>  MINUS { <http://www.Department0.University0.edu/AssistantProfessor0> 
> ub:teacherOf <http://www.Department0.University0.edu/Course38> }
> } ORDER BY ?n0 ?n1
> 
> The first three results are below.  Notice the first result contains 
> AssistantProfessor0, Course38 (violating the MINUS) and the next two results are 
> 
> redundant (shouldn't happen with DISTINCT).  Any ideas?  The NT file can be 
> found in this Zip archive I packed up for other reasons ( http://bit.ly/k8adNJ 
> ).
> 
> 
>    <result>
>      <binding name="n0">
>        http://www.Department0.University0.edu/AssistantProfessor0
>      </binding>
>      <binding name="n1">
>        http://www.Department0.University0.edu/Course38
>      </binding>
>    </result>
>    <result>
>      <binding name="n0">
>        http://www.Department0.University0.edu/AssistantProfessor0
>      </binding>
>      <binding name="n1">
>        http://www.Department0.University0.edu/Course39
>      </binding>
>    </result>
>    <result>
>      <binding name="n0">
>        http://www.Department0.University0.edu/AssistantProfessor0
>      </binding>
>      <binding name="n1">
>        http://www.Department0.University0.edu/GraduateCourse39
>      </binding>
>    </result>

Re: query where distinct and minus have no effect

Posted by Tim Harsch <ha...@yahoo.com>.
oops should have looked closer.   The DISTINCT is not violated.  Question 
remains about MINUS.




________________________________
From: Tim Harsch <ha...@yahoo.com>
To: JENA-USERS <je...@incubator.apache.org>
Sent: Fri, May 6, 2011 12:31:11 PM
Subject: query where distinct and minus have no effect

Hi,
Using the LUBM0 dataset I tried the following query in Fuseki-0.1.0.

PREFIX ub:    <http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#>
SELECT DISTINCT *
WHERE { 
  ?n0 ub:teacherOf ?n1.
  MINUS { <http://www.Department0.University0.edu/AssistantProfessor0> 
ub:teacherOf <http://www.Department0.University0.edu/Course38> }
} ORDER BY ?n0 ?n1

The first three results are below.  Notice the first result contains 
AssistantProfessor0, Course38 (violating the MINUS) and the next two results are 

redundant (shouldn't happen with DISTINCT).  Any ideas?  The NT file can be 
found in this Zip archive I packed up for other reasons ( http://bit.ly/k8adNJ 
).


    <result>
      <binding name="n0">
        http://www.Department0.University0.edu/AssistantProfessor0
      </binding>
      <binding name="n1">
        http://www.Department0.University0.edu/Course38
      </binding>
    </result>
    <result>
      <binding name="n0">
        http://www.Department0.University0.edu/AssistantProfessor0
      </binding>
      <binding name="n1">
        http://www.Department0.University0.edu/Course39
      </binding>
    </result>
    <result>
      <binding name="n0">
        http://www.Department0.University0.edu/AssistantProfessor0
      </binding>
      <binding name="n1">
        http://www.Department0.University0.edu/GraduateCourse39
      </binding>
    </result>