Newer Version Available
Statements
A SAQL query loads an input dataset,
operates on it, and outputs a results dataset. A query is made up of statements. Each SAQL statement has an input stream, an operation,
and an output stream.
A statement is made up of keywords (such as filter, group, and order), identifiers, literals, and special characters. Statements can span
multiple lines and must end with a semicolon.
Assign each query line to an identifier called a stream. The only exception to this rule is the last line in a query, which you don’t need to assign explicitly.
The output stream is on the left side of the = operator and the input stream is on the right side of the = operator.
Example
Each of the lines in this SAQL query
is a SAQL statement:
1q = load "0Fcc00000004DI1CAM/0Fd500000004F4sCAE";
2q = group q by all;
3q = foreach q generate count() as 'count', unique('OL.Helpful') as 'unique_OL.Helpful';
4limit q 2000;SAQL is compositional—you can chain statements together to operate on data sequentially. The order of SAQL statements is enforced according to how the operations in the statements change the results of a query.
The statement order rules:
- The order of filter and order can be swapped because it doesn't change the results.
- offset must be after filter and order
- offset must be before limit
- There can be no more than 1 offset statement after a foreach statement.