Using Logical Comparators
Use logical comparisons in Tamr transformation functions.
There are are many ways to compare data in Tamr. These comparators are most often used in JOIN
and FILTER
statements and case
expressions.
Syntax | Data Types | Example | Explanation |
---|---|---|---|
IS NULL | Any | state IS NULL | Returns true when “state” is a true null value. |
IS NOT NULL | Any | state IS NOT NULL | Returns true when “state” is anything other than a true null value. |
IS EMPTY | Any | state IS EMPTY | Returns true when “state” is a true null value, a blank string (a string with no content'' or a string containing only whitespace characters like spaces and tabs ' ' ), an empty array ([] ), or an array containing only blank strings and true nulls ([' ', null] ) |
IS NOT EMPTY | Any | state IS NOT EMPTY | Returns true when “state” is anything other than a true null value, a blank string a string with no content'' or a string containing only whitespace characters like spaces and tabs ' ' ), an empty array ([] ), or an array containing only blank strings and true nulls ([' ', null] ) |
== | Any | state == 'MA' | Returns true when “state” is equal to 'MA' |
= | Any | state = 'MA' | Returns true when “state” is equal to 'MA' |
!= | Any | state != 'MA' | Returns true when “state” is not equal to 'MA' |
> | Any Numeric | cost > 10.0 | Returns true when “cost” is greater than 10.0 |
>= | Any Numeric | cost >= 10.0 | Returns true when “cost” is greater than or equal to 10.0 |
< | Any Numeric | cost < 10.0 | Returns true when “cost” is less than 10.0 |
<= | Any Numeric | cost <= 10.0 | Returns true when “cost” is less than or equal to 10.0 |
Logical comparisons can be modified using NOT
to reverse its logic. Logical conditions can also be combined with AND
and OR
.
Examples:
Keep (filter down to) rows that have a populated "company_name" or have a populated parent_company_name:
FILTER company_name IS NOT EMPTY OR parent_company_name IS NOT EMPTY;
Lookup the exchange rate of a currency for a given year by matching on exact values in the year and currency columns
LOOKUP exchange_rate
FROM "currency_exchange.csv" AS currency_lookup
ON year == currency_lookup.year AND currency == currency_lookup.currency;
Create a new attribute "price_in_words", set it to 'expensive' when the price is greater than 100. Otherwise, set it to 'cheap':
SELECT *,
CASE
WHEN price > 100 THEN 'expensive'
ELSE 'cheap'
END AS price_category;
Updated over 4 years ago