Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Transitive Function (OLAP)

JoeWinter edited this page Jan 26, 2015 · 1 revision

[Table of Contents](https://github.com/dell-oss/Doradus/wiki/OLAP Databases: Table-of-Contents) | Previous | Next
Doradus Query Language: Transitive Function


The transitive function causes a _reflexive_ link to be traversed recursively, creating a set of objects for evaluation. Consider this clause:

DirectReports.Name = Fred

This clause selects people that have at least one DirectReports value whose Name is Fred. Each clause considers the immediate DirectReports of each object.

We can change the search to transitively follow DirectReports links by adding the transitive operator '^' after the reflexive link's name:

DirectReports^.Name = Fred

This selects people with a direct report named Fred or a direct report that has a second-level direct report named Fred, recursively down the org chart. The transitive operator '^' expands the set of objects evaluated in the place where the reflexive link (DirectReports) occurs recursively. The recursion stops when either:

  • A cycle is detected: If an object is found that was already visited in evaluating the DirectReports^ expression, that object is not evaluated again.
  • A null is detected: The recursion stops at the "edges" of the graph, in this case someone with no direct reports.

In some cases, we know that a reflexive graph is not very deep for any given object, so we can let the recursion continue until the leaf nodes are reached. But in some cases, the graph may be arbitrarily large and we need to restrict the number of levels searched. In this case, a limit can be passed to the transitive operator in parentheses:

DirectReports^(5).LastName = Smith

This clause selects people with any direct report up to 5 levels deep whose last name is Smith.

The transitive function can be combined with quantifiers as shown below:

ALL(InternalRecipient.Person).Manager^.Name : Fred

This clause selects messages whose every internal recipient has a superior (manager, manager's manager, etc.) named Fred.

The transitive function can also be used with WHERE filter clauses, as long as the filter appears after the transitive operator. For example:

Manager^.WHERE(LastName=Smith).FirstName : Do*

This query searches “up” the org chart for all Manager objects. Only managers whose LastName is Smith and whose FirstName begins with the letters do are selected.

Clone this wiki locally