fluree / core

Fluree releases and public bug reports
0 stars 0 forks source link

SPARQL <--> FlureeQL Parity (Regex, Union, Query by Subject IRI) #90

Open flureeadmin opened 5 months ago

flureeadmin commented 5 months ago

Description

Our client, BfR, has found 3 SPARQL query scenarios which don't seem to work:

BfR would like to be able to issue SPARQL queries that leverage these three patterns, as they already have application code in place that uses SPARQL

There is also a request to allow the use of a instead of <@type>, as that's more consistent with SPARQL usage generally. If that's doable in this ticket, I'd love to include that, but if it's complex enough to also separate that into it's own ticket, I can do that too (at a lower priority)

Test Examples & Responses

Regex Filtering

PREFIX psm: <http://srv.ktbl.de/data/psm/>
PREFIX schema: <http://schema.org/>

#Not_working

SELECT ?s ?t ?name
FROM <cookbook/base>
WHERE {
    ?s <@type> ?t.
    ?s schema:name ?name.
    FILTER regex(?name, "^Jon", "i")
}

Union Queries

I think this might just be a serialization issue because the error looks like it's being parsed correctly

PREFIX person: <http://person.com/ns/>

SELECT ?person ?age
FROM <cookbook/base>
WHERE {
    {?person person:age 70.
    ?person person:handle "dsanchez".}
    UNION {?person person:handle "anguyen".}
    ?person person:age ?age .
}

And the error returned:

{
    "error": "db/invalid-query",
    "message": "Error in value for \"where\"; where clause must be a single node map pattern or a sequence of where patterns; Provided: [[:union [[{:@id \"?person\", :person:age 70} {:@id \"?person\", :person:handle \"dsanchez\"}] [{:@id \"?person\", :person:handle \"anguyen\"}]]] {:@id \"?person\", :person:age \"?age\"}];  See documentation for details: https://next.developers.flur.ee/docs/reference/errorcodes#query-invalid-where"
}

Query by Subject IRI

PREFIX psm: <http://srv.ktbl.de/data/psm/>
PREFIX ex: <http://example.org/>

SELECT ?p ?o
FROM <cookbook/base>
WHERE {
    ex:andrew ?p ?o. # Should provide just the triples related to andrew
}

Seems to return all pred-object values, not just the ones on ex:andrew:

[
    [
        "@id",
        "http://schema.org/Organization"
    ],
    [
        "@id",
        "http://example.org/Monster"
    ],
    [
        "@id",
        "http://example.org/mosquitos"
    ],
    [
        "@type",
        "ex:Monster"
    ],
    [
        "http://schema.org/description",
        "We ❤️ Human Blood"
    ],
    [
        "@id",
        "http://example.org/w3c"
    ],
    ...
]
aaj3f commented 5 months ago

Notes from @quoll: