JBoss Community Archive (Read Only)

Teiid 8.6

Criteria

Criteria may be:

Usage:

Matches the string expression against the given string pattern. The pattern may contain % to match any number of characters and _ to match any single character. The escape character can be used to escape the match characters % and _.

SIMILAR TO is a cross between LIKE and standard regular expression syntax. % and _ are still used, rather than .* and . respectively.

Note

Teiid does not exhaustively validate SIMILAR TO pattern values. Rather the pattern is converted to an equivalent regular expression. Care should be taken not to rely on general regular expression features when using SIMILAR TO. If additional features are needed, then LIKE_REGEX should be used. Usage of a non-literal pattern is discouraged as pushdown support is limited.

LIKE_REGEX allows for standard regular expression syntax to be used for matching. This differs from SIMILAR TO and LIKE in that the escape character is no longer used (\ is already the standard escape mechanism in regular expressions and % and _ have no special meaning. The runtime engine uses the JRE implementation of regular expressions - see the java.util.regex.Pattern class for details.

Note

Teiid does not exhaustively validate LIKE_REGEX pattern values. It is possible to use JRE only regular expression features that are not specified by the SQL specification. Additional not all sources support the same regular expression flavor or extensions. Care should be taken in pushdown situations to ensure that the pattern used will have same meaning in Teiid and across all applicable sources.

Teiid converts BETWEEN into the equivalent form expression >= minExpression AND expression <= maxExpression

Where expression has type boolean.

Syntax Rules:

Some examples of valid criteria are:

Comparing null Values

Null values represent an unknown value. Comparison with a null value will evaluate to 'unknown', which can never be true even if 'not' is used.

Criteria Precedence

Teiid parses and evaluates conditions with higher precedence before those with lower precedence. Conditions with equal precedence are left associative. Condition precedence listed from high to low:

Condition

Description

sql operators

See Expressions

EXISTS, LIKE, SIMILAR TO, LIKE_REGEX, BETWEEN, IN, IS NULL, <, <=, >, >=, =, <>

comparison

NOT

negation

AND

conjunction

OR

disjunction

Note however that to prevent lookaheads the parser does not accept all possible criteria sequences.  For example "a = b is null" is not accepted, since by the left associative parsing we first recognize "a =", then look for a common value expression.  "b is null" is not a valid common value expression.  Thus nesting must be used, for example "(a = b) is null".  See BNF for SQL Grammar for all parsing rules.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 12:50:14 UTC, last content change 2012-10-11 13:23:29 UTC.