Perform boolean logic operations.
Logical functions perform boolean operations on one or more values. They are crucial for:
Key features:
Support for various data types:
Flexible syntax options:
and(a, b)
)a AND b
)These functions enable you to create readable and expressive logical expressions in your queries, enhancing both clarity and functionality.
Logical functions perform boolean operations on one or more values.
Calculates the logical conjunction of two or more values.
Syntax:
Alternatively, you can use the AND
operator:
Alias:
AND
operatorArguments:
val1
, val2
, … (Int
, UInt
, Float
, or Nullable
): List of at least two values.Returns:
0
if at least one argument evaluates to falseNULL
if no argument evaluates to false and at least one argument is NULL1
otherwiseReturn type: UInt8
or Nullable(UInt8)
Example:
In this example, should_celebrate
is true only when it’s Taco Tuesday, there’s guacamole, and more than 3 tacos are available.
Result:
Calculates the logical disjunction of two or more values.
Syntax:
Alias:
OR
operatorArguments:
val1
, val2
, … (Int
, UInt
, Float
, or Nullable
): List of at least two values.Returns:
1
if at least one argument evaluates to true0
if all arguments evaluate to falseNULL
if all arguments evaluate to false and at least one argument is NULLReturn type: UInt8
or Nullable(UInt8)
.
Example:
Result:
In this example, hasProteinOption
is true if at least one protein option (carnitas, chicken, or beef) is available.
Calculates the logical negation of a value.
Syntax:
Alias:
!
Arguments:
val
(Int
, UInt
, Float
, or Nullable
): The value.Returns:
1
if val
evaluates to false0
if val
evaluates to trueNULL
if val
is NULLReturn type: UInt8
or Nullable(UInt8)
.
Example:
Result:
In this example, isMild
is the logical negation of isSpicy
.
Calculates the logical exclusive disjunction of two or more values. For more than two input values, the function first xor-s the first two values, then xor-s the result with the third value, and so on.
Syntax:
Arguments:
val1
, val2
, … (Int
, UInt
, Float
, or Nullable
): List of at least two values.Returns:
1
if one of the values evaluates to false and the other does not0
if both values evaluate to false or both trueNULL
if at least one of the inputs is NULLReturn type: UInt8
or Nullable(UInt8)
.
Example:
Result:
In this example, hasUniqueTopping
is true if exactly one of salsa, guacamole, or sour cream is present on the taco.
Calculates the logical negation of a value.
Syntax:
Alternatively, you can use the negation operator:
Arguments:
val
(Int
, UInt
, Float
, or Nullable
): The value to negate.Returns:
1
if val
evaluates to false0
if val
evaluates to trueNULL
if val
is NULLType: UInt8
or Nullable(UInt8)
Example:
Result:
In this example:
not(1)
returns 0 because 1 is considered truenot(0)
returns 1 because 0 is considered falsenot(NULL)
returns NULLnot(isHot('jalapeño'))
returns 0, assuming jalapeños are considered hotThe not
function treats any non-zero value as true and zero as false. This applies to all numeric types, including floating-point numbers.
Perform boolean logic operations.
Logical functions perform boolean operations on one or more values. They are crucial for:
Key features:
Support for various data types:
Flexible syntax options:
and(a, b)
)a AND b
)These functions enable you to create readable and expressive logical expressions in your queries, enhancing both clarity and functionality.
Logical functions perform boolean operations on one or more values.
Calculates the logical conjunction of two or more values.
Syntax:
Alternatively, you can use the AND
operator:
Alias:
AND
operatorArguments:
val1
, val2
, … (Int
, UInt
, Float
, or Nullable
): List of at least two values.Returns:
0
if at least one argument evaluates to falseNULL
if no argument evaluates to false and at least one argument is NULL1
otherwiseReturn type: UInt8
or Nullable(UInt8)
Example:
In this example, should_celebrate
is true only when it’s Taco Tuesday, there’s guacamole, and more than 3 tacos are available.
Result:
Calculates the logical disjunction of two or more values.
Syntax:
Alias:
OR
operatorArguments:
val1
, val2
, … (Int
, UInt
, Float
, or Nullable
): List of at least two values.Returns:
1
if at least one argument evaluates to true0
if all arguments evaluate to falseNULL
if all arguments evaluate to false and at least one argument is NULLReturn type: UInt8
or Nullable(UInt8)
.
Example:
Result:
In this example, hasProteinOption
is true if at least one protein option (carnitas, chicken, or beef) is available.
Calculates the logical negation of a value.
Syntax:
Alias:
!
Arguments:
val
(Int
, UInt
, Float
, or Nullable
): The value.Returns:
1
if val
evaluates to false0
if val
evaluates to trueNULL
if val
is NULLReturn type: UInt8
or Nullable(UInt8)
.
Example:
Result:
In this example, isMild
is the logical negation of isSpicy
.
Calculates the logical exclusive disjunction of two or more values. For more than two input values, the function first xor-s the first two values, then xor-s the result with the third value, and so on.
Syntax:
Arguments:
val1
, val2
, … (Int
, UInt
, Float
, or Nullable
): List of at least two values.Returns:
1
if one of the values evaluates to false and the other does not0
if both values evaluate to false or both trueNULL
if at least one of the inputs is NULLReturn type: UInt8
or Nullable(UInt8)
.
Example:
Result:
In this example, hasUniqueTopping
is true if exactly one of salsa, guacamole, or sour cream is present on the taco.
Calculates the logical negation of a value.
Syntax:
Alternatively, you can use the negation operator:
Arguments:
val
(Int
, UInt
, Float
, or Nullable
): The value to negate.Returns:
1
if val
evaluates to false0
if val
evaluates to trueNULL
if val
is NULLType: UInt8
or Nullable(UInt8)
Example:
Result:
In this example:
not(1)
returns 0 because 1 is considered truenot(0)
returns 1 because 0 is considered falsenot(NULL)
returns NULLnot(isHot('jalapeño'))
returns 0, assuming jalapeños are considered hotThe not
function treats any non-zero value as true and zero as false. This applies to all numeric types, including floating-point numbers.