Logical Operators (U-SQL)
U-SQL supports the C# logical operators &&, || and ! (not). Since C# guarantees order of execution and provides short-cutting on logical operators, these operators can incur a slight performance penalty. The C# semantics does not allow the optimizer to rewrite and reorder the query predicates. For example, the second predicate in a logical expression cannot be moved up in the execution tree to apply the filter early, because it would now be executed before the first predicate.
Since such query rewrites are often useful to improve query performance, U-SQL also supports the SQL-inspired AND, OR and NOT operators. In order to give the optimizer better choices, these operators should be used instead of the C# operators if the execution order among the two predicates does not need to be preserved.
Note that unlike the ANSI SQL operators, these operators are still operating according to C#’s two-valued Boolean Logic, meaning that they do not support null values as a third logical value.
Logical Operators build up the Boolean_Expression as follows:
Boolean_Expression := bool_expression | ('NOT' | '!') Boolean_Expression | Boolean_Expression ('AND' | '&&') Boolean_Expression | Boolean_Expression ('OR' | '||') Boolean_Expression.