Select
Filters out data based on specified condition.
Usage
select (data, condition : selected-data)
Details
The condition is similar to a SQL WHERE clause expression.
Conjunctive, disjunctive, and negated condition expressions can be
constructed by using and, or, and
not. The following comparators are allowed:
- =, !=, <, <=, >, >=
- +like
- +notlike
To compare against string and date literals, these literals must be
explicitly denoted as string and date types:
- Strings must be single-quoted (before and after)
- EXAMPLE: name != 'Jane Doe'
- Dates must be prepended with the @ character and should be expressed in MM-dd-yyyy format.
- EXAMPLE: hire_date < @01-20-1985
- Times must be prepended with the ~ character and should be expressed in hh:mma format.
- EXAMPLE: flight_time < ~8:00pm
When using like/notlike:
- The + character must be prepended and the wildcard character is %.
- EXAMPLE: name +like 'A% B%'
- +like and +notlike can only be used when comparing character attributes
Notes
- When determining the condition, ONLY the first tuple of the
conditions stream will be used - all others will be ignored.
If multiple conditions are required, use and, or,
and parentheses as necessary.
Known Bugs
- Case matters: the tokens and, or, not, +like, +notlike need
to be lowercased. This is a limitation of the underlying expression
parser.
Example
Using the input:
RELATION books: title char, author char, pub_date date, pages number
Title1|Author1|09-01-1991|34
Title2|Author2|12-23-1954|479
Title3|Author2|05-09-2002|733
Title4|Author3|01-01-1968|32
Title5|Author2|07-03-2001|1152
when executing the plan:
PLAN test
{
INPUT: stream books
OUTPUT: stream answer
BODY
{
select (books, "(pages < 100) and (pub_date <= @01-01-1990)" : answer)
}
}
will generate the following output:
----------------------------------------------
RELATION: test_answer
attrs: title, author, pub_date, pages
----------------------------------------------
Title4|Author3|01-01-1968|32
----------------------------------------------