Skip to content

Expand support of TYPE extraction for literals and predicates too, in addition to nodes #124

@rogerlucena

Description

@rogerlucena

Currently, the TYPE keyword can be used to extract types only from nodes. In the case of a node like /u<paul> it would extract /u, for example.

But, as a feature request, it would be interesting to be able to extract "types" from predicates and literals as well, and also be able to use them in HAVING clauses to filter our results.

To illustrate, it would be nice that BQL supported queries such as:

SELECT ?s, ?p, ?o, ?o_type
FROM ?test
WHERE {
  ?s ?p ?o TYPE ?o_type
}
HAVING ?o_type = ^^type:float64;

On which it would understand that we want triples that have an object that is a literal, and that this literal is specifically a float64 literal.

In a similar way, we could use ^^type:int64 for int64 literals and ^^type:text for text literals, and so on.

For predicates, the HAVING clause could be:

HAVING ?o_type = ^^type:predicate;

(useful in the case of reification and blank nodes)

Or even:

HAVING ?o_type = ^^type:predicate:immutable;

To specifically query for immutable predicates. We could analogically use ^^type:predicate:temporal to specifically query for temporal predicates as well.

In the case of nodes, the HAVING clause could be:

HAVING ?o_type = ^^type:/u;

If we wanted only node objects with type /u (the users in our database).

This feature would be useful in a number of scenarios, as illustrated.

Also, for coherence, it is important to remember that, in SELECT queries, the result for TYPE bindings should also follow the same pattern as above. To illustrate, the query:

SELECT ?o, ?o_type
FROM ?test
WHERE {
  ?s ?p ?o TYPE ?o_type
};

Should now return something like:

Result:
?o			?o_type
/u<paul>		^^type:/u
"3.7"^^type:float64	^^type:float64
"hello"^^type:text    	^^type:text
"parent_of"[]    	^^type:predicate:immutable 	

For consistency.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions