Hello Christian,

>> sparql SELECT ?s WHERE {?s ?p ?o. FILTER(regex(?o, "Education"))};
> *** Error 22023: [Virtuoso Driver][Virtuoso Server]SR375: Invalid argument
2 to regexp_match. Must be narrow or wide string at line 1 of

Can I download sample data? This case demonstrates an error in server and it
should be fixed.



>> sparql PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>SELECT ?publ ?p1 ?p1mail ?p2 ?p2mail ?p3 ?p3mail WHERE {
    ?publ <http://test/#publicationAuthor> ?p1.
    ?p1 <http://test/#emailAddress> ?p1mail
    OPTIONAL { ?publ <http://test/#publicationAuthor> ?p2.
        ?p2 <http://test/#emailAddress> ?p2mail.
        FILTER(?p1 != ?p2) }
    OPTIONAL {
        ?publ <http://test/#publicationAuthor> ?p3.
        ?p3 <http://test/#emailAddress> ?p3mail.
        FILTER(?p1 != ?p3 && ?p2 != ?p3) }
    } LIMIT 10;
*** Error 37000: [Virtuoso Driver][Virtuoso Server]SQ074: Line 1:
SP031: SPARQL compiler: Variable 'p2' is used in subexpressions of the query
but not assigned at ';' immediately before end of statement at line 2 of
Top-Level:

Yes we had a version that compiled this query but we intentionally added the
strict check that signals an error. The check is by default disabled, but
unfortunately it is not entirely disabled.
Virtuoso does not allow unbound variables in filters because if they're
allowed then it is always impossible to catch some sorts of typos in a
SPARQL subquery of SQL expression.
Moreover, such variables often indicates misunderstanding of difference
between SPARQL FILTER and SQL WHERE (final SPARQL spec might contain more
detailed explaination of the thing).

Consider the first OPTIONAL with a FILTER:
    OPTIONAL { ?publ <http://test/#publicationAuthor> ?p2.
        ?p2 <http://test/#emailAddress> ?p2mail.
        FILTER(?p1 != ?p2) }

Unlike SQL, all used ?p1 bindings will be taken solely from the OPTIONAL
{...} clause. There are no bindings of ?p1 in that clause at all so the
FILTER condition should get same value regardless ?p1 binding outside the
clause. This is probably not what you need.

If you rewrite the query like

sparql PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?publ ?p1 ?p1mail ?p2 ?p2mail ?p3 ?p3mail WHERE {
    ?publ <http://test/#publicationAuthor> ?p1.
    ?p1 <http://test/#emailAddress> ?p1mail
    OPTIONAL {
        ?publ <http://test/#publicationAuthor> ?p2.
        ?p2 <http://test/#emailAddress> ?p2mail }
    OPTIONAL {
        ?publ <http://test/#publicationAuthor> ?p3.
        ?p3 <http://test/#emailAddress> ?p3mail }
    FILTER (
      (!BOUND(?p2) || (?p1 != ?p2)) &&
      (!BOUND(?p3) || (?p1 != ?p3)) &&
      (!BOUND(?p2) || !BOUND(?p3) || (?p2 != ?p3)) ) }
LIMIT 10;

?p1 will be bound inside the WHERE {...} clause that immediately contains
the FILTER in question so it will really eliminate some resultset rows. This
seemes to be abnormally verbose but SPARQL is designed to be effecient for
fedarated querying whereas common use of SQL is querying of a single box.

Best Regards,
IvAn.

-----Original Message-----
From: virtuoso-users-boun...@lists.sourceforge.net
[mailto:virtuoso-users-boun...@lists.sourceforge.net] On Behalf Of Christian
Weiske
Sent: Sunday, August 05, 2007 06:35
To: virtuoso-users@lists.sourceforge.net
Subject: Re: [Virtuoso-users] virtuoso + iodbc

Hello all,


I got Virtuoso working without iodbc config flag and used isql to benchmark
some queries on rdf data sets from 5 to 200.000 triples.

As expected, Virtuoso was the fastest among the tested engines; a bit more
than twice as fast as my engine (that is in RAP, RDF API for PHP) and even
more fast than the other engines (Redland, Jena, ARC).
Once I come to rest I will publish the detailled results.

What I would like to know you is that Virtuoso's SPARQL engine has some
problems with certain queries that work flawless on other engines:

--------
SQL> sparql SELECT ?s WHERE {?s ?p ?o. FILTER(regex(?o, "Education"))};

*** Error 22023: [Virtuoso Driver][Virtuoso Server]SR375: Invalid argument 2
to regexp_match. Must be narrow or wide string at line 1 of
Top-Level:

--------
SQL> sparql PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?publ ?p1 ?p1mail ?p2 ?p2mail ?p3 ?p3mail WHERE { ?publ
<http://test/#publicationAuthor> ?p1. ?p1 <http://test/#emailAddress>
?p1mail OPTIONAL { ?publ <http://test/#publicationAuthor> ?p2. ?p2
<http://test/#emailAddress> ?p2mail. FILTER(?p1 != ?p2)}OPTIONAL { ?publ
<http://test/#publicationAuthor> ?p3. ?p3 <http://test/#emailAddress>
?p3mail. FILTER(?p1 != ?p3 && ?p2 != ?p3) }} LIMIT 10;
*** Error 37000: [Virtuoso Driver][Virtuoso Server]SQ074: Line 1:
SP031: SPARQL compiler: Variable 'p2' is used in subexpressions of the query
but not assigned at ';' immediately before end of statement at line 2 of
Top-Level:
--------


Beside that I found it to be a huge pain in the stomach that Virtuoso does
not have a native way to delete rows and limit the number of rows.
In e.g. MySQL you can do
> DELETE FROM table LIMIT 10
which would delete 10 rows only. Sometimes (as in my case) it does not
matter at all which rows are deleted, only the number counts.
I tried both SQL and SPARQL.
In the end I wrote my own stored procedure that has a parameter of the
number of rows to delete and selects always one single row and deletes it
until a counter reaches the desired number.

--
Regards/Mit freundlichen Grüßen
Christian Weiske


Reply via email to