Document toolboxDocument toolbox

autoJoinTables Macro

[ 1 Syntax: ] [ 2 Examples: ] [ 3 Semantic: ] [ 4 Use Case: ]

Syntax:

LQL

@autoJoinTables(parent: TableReference, children: TableReferenceList, [result: TableResultList])

If result is omitted, the value parent +: children is used.

Examples:

LQL

@autoJoinTables(P, [C1, C2, C3]) # equivalent to @autoJoinTables(P, [C1, C2, C3], [P, C1, C2, C3])

LQL

@autoJoinTables(P, [C1, C2, C3], [P, C2])

Semantic:

The macro expands to autoJoinTables(joinTables, result), where joinTables is the distinct concatenation of reverseDfsOrder(parent, child) for every child table in children, and reverseDfsOrder(p, c) is the reverse of the DFS ordering obtained by traversing the inverted subdag between p and c starting from c.

In other words, joinTables is the set of all nodes on every path between a child and the parent node, ordered in a specific way to make autoJoinTables work.

The documentation for the autoJoinTables operator is here.

Use Case:

Suppose you have tables similar to

Now, if you were to use autoJoinTables operator, you'd write:

LQL

i.e. you have to specify all intermediate nodes from a1 to head as well as b1 to head as well as c1 to head in order,
but with @autoJoinTables macro, it becomes slightly easier:

LQL