Logic Functions
Case
returns the value for the first true when-expression
Syntax:
Case(when x then y
[when x2 then y2 ...]
[default y3])
Examples:
Case(when 3 < 4 then "foo" default "bar") = "foo"
Case(when 3 > 4 then "foo") is null
Case(when false then 1 when true then 2) = 2
Coalesce
returns first non-null argument or null if all are null
Syntax:
Coalesce(x [, ...]) -> any
Examples:
Coalesce(null, null, 3, 4) = 3
Coalesce(1, null) = 1
Coalesce(Int(null)) is null
If
returns x if condition is true, otherwise returns y
Syntax:
If(condition bool, x, y) -> any
Examples:
If(true, 1, -1) = 1
If(false, "yes", "no") = "no"
IfNull
returns x if it is non-null, otherwise returns y
Syntax:
IfNull(x, y) -> any
Examples:
IfNull(null, 5) = 5
IfNull("a", "b") = "a"
Type
returns type of argument as a string
Syntax:
Type(x) -> string
Examples:
Type(7) = "int"
Type(1.5) = "float"
Type([EventTime()]) = "[time]"
Type(Bool(null)) = "bool"
Type(null) = "unknown"
And
returns the logical AND of the conditions. Handles nulls using three-valued logic
Syntax:
And(conditions bool [, ...]) -> bool
Examples:
And(true, false) is false
And(true, true) is true
And(true, null) is null
(false and null) is false
And(true, true, false) is false
And() is true
Assert
returns an error if condition is null or false
Syntax:
Assert(condition bool, [msg string]) -> bool
Examples:
Assert(3 > 4, "3 is not greater than 4") is false
Assert(null, "input is null") is null
Assert(4 > 3) is true
Assert(Contains("haystack", "needle")) is false
Bool
converts argument to a boolean value (true/false)
Syntax:
Bool(x) -> bool
Examples:
Bool(0) = false
Bool(5.3) = true
Bool("") = false
Bool("False") = false
Bool(null) is null
IsNull
returns whether argument is null
Syntax:
IsNull(x) -> bool
Examples:
IsNull(null) = true
IsNull("foo") = false
(5 is null) = false
Not
returns the logical NOT of the condition
Syntax:
Not(condition bool) -> bool
Examples:
Not(true) = false
Not(null) is null
(not false) = true
Or
returns the logical OR of the conditions. Handles nulls using three-valued logic
Syntax:
Or(conditions bool [, ...]) -> bool
Examples:
Or(true, false) is true
Or(false, false) is false
Or(true, null) is true
(false or null) is null
Or(false, false, true) is true
Or() is false