Pruning

Stop a walk where it no longer matters.

Syntax

Write PRUNE after the edge collection (and after BFS or DFS, if you give one), with a key and a quoted value.

FOR v IN 1..5 OUTBOUND "gid://namespace/resource/id" name_edge
  PRUNE type = "customer"

Parameters and arguments

  • type = "…"

    The type of record to stop at, written as a key, an equals sign and a quoted value. The key can carry the vertex name, as in v.type; the engine reads the value, not the key's name. The value is the type stored on the far end of the edge, such as customer

    Required: Yes

Examples

Walk outbound from an order, and do not go past a customer. The content store holds no edges, so the answer shows the shape with no results.

Return type and behaviour

A record of the pruned type is returned, but the walk does not expand beyond it. Records at greater depths along that route are not reached. The type is the type stored on the edge's far end (_to_type for an outbound walk, _from_type for an inbound one).

Errors and exceptions
ErrorWhat happenedHow to recover
HTQL-1003The traversal is not written in HTQL's grammarCheck the range, the direction, the start and the edge collection
HTQL-2012The edge collection's name is not in lower snake caseWrite a name such as placed_by_edge
HTQL-2012The PRUNE value has characters other than letters, digits and underscoresWrite a type name such as customer
Placement and context

PRUNE follows the edge collection and the BFS or DFS keyword, and comes before FILTER and RETURN.

Permissions and security

PRUNE only narrows a walk. The walk follows the edges the caller may read.

Best practices
  • Prune at the kind of record that ends the part of the graph you need.
  • Combine PRUNE with a small depth.