AQL contains several built-in table functions, similar to the user-defined table functions in commercial SQL implementations. A table function is a function that produces a relational table as output every time it is called. An AQL expression can treat the output of a table function as an input:
select ... from TableFunc( ... );
The current set of AQL table functions all take a relation as input. This section lists the built-in table functions in alphabetical order.
The Block
table function looks for blocks of contiguous (or nearly
so) spans in its input. Block
takes either three or four
arguments:
Block(<maxchars>, <minspans>, [<maxspans>], <viewname>.<colname>)
Here, <maxchars> is the maximum number of characters that can be between two spans for them to be considered "contiguous", and <minspans> is the minimum number of spans required for a block. The optional <maxspans> argument specifies an upper bound on the number of spans that can be considered in a block. For example:
Block(200, 3, FirstName.name)
finds blocks of 3 or more "first name" spans within at most 200 characters of each other.
For every such block it finds, Block
produces an output tuple with
a single column called "block". Note that Block
finds every
possible block in its input, even if some of those blocks overlap with each
other.
The BlockTok
table function is a version of Block
that measures distances in terms of tokens instead of characters. This table
function uses the same tokenization as the extract statement (See the section called “Token Constraints”). For the purposes of BlockTok
,
a token is defined as one of the following:
Whitespace does not count as a token.
BlockTok
takes four arguments:
BlockTok(<maxtoks>, <minspans>, <maxspans>, <viewname>.<colname>)
The semantics of the arguments are the same as for Block
, except
that distances are measured in tokens and the <maxspans> argument is
mandatory. In particular, the algorithm that BlockTok() uses to measure the
distance betweens S1
and S2
is as follows:
t := text between S1 and S2 if (number of tokens in t <= maxtoks) then S1 and S2 are within qualifying distance endif