It's getting curiousor and curiousor...

Using the TBC SPARQL tab, when I call a function that filters according
to an argument, e.g.:

SELECT ?user
WHERE {
    ?project ModelManagement:hasUser ?user .
    ?user Common:name ?username .
    FILTER (?username = ?arg1) .
}

As long as I pass in an argument that has a match:

SELECT ?value
WHERE {LET(?user := ModelManagement:getProjectUser("john"))
               ?user ModelManagement:firstName ?value}
 
the function returns just one result as expected (in this case for some
reason the blank result rows aren't returned).  However, if I pass in a
value that has NO matches:

SELECT ?value
WHERE {LET(?user := ModelManagement:getProjectUser("xxx"))
               ?user ModelManagement:firstName ?value}

It acts like the FILTER statement isn't there, and all User's names in
the model are returned.  I would have expected no results to be
returned.  Btw, I'm seeing this same behavior in my code too.  Am I
thinking about this wrong, or is there perhaps a problem with how FILTER
works within a Function?

Jeff





> -----Original Message-----
> From: Schmitz, Jeffrey A 
> Sent: Wednesday, May 27, 2009 1:15 PM
> To: [email protected]
> Subject: [tbc-users] Re: [SPIN] Using FILTER with function arguments
> 
> On a related note...
> 
> "(or at least not return the result as a valid binding)."
> 
> It's interesting that the number of rows returned from such a 
> query in TBC (and I assume in the code) seems to be based on 
> what would be returned if the FILTER statement wasn't there, 
> even if the rows end up having no bindings.  In the attached 
> screenshot, there are 4 rectangles in the model being 
> queried, only one of which is a square.  Note the three empty 
> result rows returned. So the variable returned from a 
> function call acts as an OPTIONAL binding by default (the 
> opposite of regular variables).  And I never thought there'd 
> be any reason to use FILTER (bound(?x)), but now there is.  
> If you want the function to actually filter (something I was 
> hoping to right a lot of functions to precisely do), you 
> should be able to do something like:
> 
> SELECT ?value
> WHERE {
>     ?rec spinsquare:width ?width .
>     ?rec spinsquare:height ?height .
>    LET (?value := SpinLib:twoDimArea(?width, ?height)) .
>   FILTER(bound(?value))
> }
> 
> No?
> 
> Jeff
> 
> 
> 
> 
> 
>  
> 
> > -----Original Message-----
> > From: Holger Knublauch [mailto:[email protected]]
> > Sent: Wednesday, May 27, 2009 12:37 PM
> > To: [email protected]
> > Subject: [tbc-users] Re: [SPIN] Using FILTER with function arguments
> > 
> > 
> > Hi Jeff,
> > 
> > I can't see how this is limited to SPIN - the same should 
> happen with 
> > any other function. Could you try to put something else 
> into the LET 
> > clause? The ARQ engine should simply never call the LET after the 
> > FILTER (or at least not return the result as a valid binding).
> > 
> > Holger
> > 
> > 
> > On May 27, 2009, at 10:23 AM, Schmitz, Jeffrey A wrote:
> > 
> > >
> > > Hello,
> > >   I'm having trouble when using SPIN function arguments within a 
> > > FILTER statement.  E.g. using the spinsquare model I
> > initially added a
> > > simple twoDimArea function that seems to work correctly:
> > >
> > > SELECT ?result
> > > WHERE {
> > >    LET (?result := (?arg1 * ?arg2)) .
> > > }
> > >
> > > When I call it with something like:
> > >
> > > SELECT ?value
> > > WHERE {
> > >   ?rec spinsquare:width ?width .
> > >   ?rec spinsquare:height ?height .
> > >   LET (?value := SpinLib:twoDimArea(?width, ?height)) }
> > >
> > > the correct values are returned based on what's in the model.   
> > > However,
> > > if I change the function query to filter out everything except
> > > squares:
> > >
> > > SELECT ?result
> > > WHERE {
> > >    FILTER (?arg1 = ?arg2) .
> > >    LET (?result := (?arg1 * ?arg2)) .
> > > }
> > >
> > > The filtering doesn't happen, I still get all the results.  
> > I've tried
> > > other variations of FILTER statements that uses only one
> > argument and
> > > none of them seem to do any filtering.  Should FILTER statements 
> > > within SPIN Functions work?
> > >
> > > Thanks,
> > > Jeff
> > >
> > > >
> > 
> > 
> > > 
> > 
> 
> > 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TopBraid Composer Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/topbraid-composer-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to