#20 FILTER weirdness

open
nobody
None
5
2014-08-16
2008-03-20
Marcus Cobden
No

I've been using the FILTER constraint and have noticed some weirdness.
The following Queries generate different results.
The fist matches nothing for some reason, while the second matches what you might expect

SELECT ?p ?o ?t WHERE{
$uri ?p ?o . FILTER (?p != rdf:type)
?o rdf:type ?t
}

SELECT ?p ?o ?t WHERE{
$uri ?p ?o . FILTER (! (?p = rdf:type) )
?o rdf:type ?t
}

Discussion

  • Steve Harris
    Steve Harris
    2008-03-21

    Logged In: YES
    user_id=17241
    Originator: NO

    How strange! Can you add the version of mysql you're using and the results of an "explain" of that query?

    Thanks,
    Steve

     
  • Marcus Cobden
    Marcus Cobden
    2008-03-21

    Logged In: YES
    user_id=1879346
    Originator: YES

    Server version: 4.1.20

    [mc@cohen dev]$ /usr/local/bin/ts-explain -d wiki -f ascii 'PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?p ?o ?t WHERE{
    > <http://wiki.rkbexplorer.com/id/hugh_glaser> ?p ?o . FILTER (! (?p = rdf:type))
    > ?o rdf:type ?t .
    > }'
    Complexity: 788
    SELECT v0.lexical AS `p`, v1.lexical AS `o`, v2.lexical AS `t`, v2.datatype AS t_dt, v2.language AS t_lang
    FROM (SELECT t0.subject AS `o`, t2.predicate AS `p`, t0.object AS `_TV0`, t1.object AS `t`
    FROM triples t0, triples t1, triples t2, symbols v0
    WHERE v0.hash=t2.predicate
    AND t2.predicate=v0.hash
    AND NOT ((v0.hash<0 && v0.lexical="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))
    AND t2.object=t0.subject
    AND t2.subject=-6624406073138561458
    AND t1.predicate=-5275523445234180533
    AND t1.subject=t0.object
    AND t0.predicate=-4085280037482734459
    ) AS `tmp0_7147`, symbols v0, symbols v1, symbols v2
    WHERE tmp0_7147.p=v0.hash && tmp0_7147.o=v1.hash && tmp0_7147.t=v2.hash
    ;

    [mc@cohen dev]$ /usr/local/bin/ts-explain -d wiki -f ascii 'PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?p ?o ?t WHERE{
    > <http://wiki.rkbexplorer.com/id/hugh_glaser> ?p ?o . FILTER (?p != rdf:type)
    > ?o rdf:type ?t .
    > }'
    Complexity: 91
    SELECT v0.lexical AS `p`, v1.lexical AS `o`, v2.lexical AS `t`, v2.datatype AS t_dt, v2.language AS t_lang
    FROM (SELECT t0.subject AS `o`, t2.predicate AS `p`, t0.object AS `_TV0`, t1.object AS `t`
    FROM triples t0, triples t1, triples t2, symbols v0
    WHERE v0.hash=t2.predicate
    AND t2.predicate=v0.hash
    AND (v0.hash<0 && v0.lexical!="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" && v0.datatype IN (0,2,4,5,6,7))
    AND t2.object=t0.subject
    AND t2.subject=-6624406073138561458
    AND t1.predicate=-5275523445234180533
    AND t1.subject=t0.object
    AND t0.predicate=-4085280037482734459
    ) AS `tmp0_7148`, symbols v0, symbols v1, symbols v2
    WHERE tmp0_7148.p=v0.hash && tmp0_7148.o=v1.hash && tmp0_7148.t=v2.hash
    ;

     
  • Steve Harris
    Steve Harris
    2008-03-21

    Logged In: YES
    user_id=17241
    Originator: NO

    OK, the problem is the
    v0.datatype IN (0,2,4,5,6,7)
    production, but I'm not quite sure where it's coming from.