google / google/badwolf

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

Open
#124 2 comments 0 reactions 0 assignees View on GitHub
feature request
Dominant language
Go
Stars
984
Forks
65
PR merge metrics
No merged PRs in 30d

Description

Currently, the TYPE keyword can be used to extract types only from nodes. In the case of a node like `/u` 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 ^^type:/u
"3.7"^^type:float64 ^^type:float64
"hello"^^type:text ^^type:text
"parent_of"[] ^^type:predicate:immutable
```

For consistency.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.