Conditional Functions

Query service supports the following conditional functions.

FunctionReturn TypeInput ArgumentsDescription
coalesce(arg1, arg2, ...)Same as the input
  • arg1, arg2, ...: Any data type
Returns the first non-null value in the argument list.
if(condition, true_value, false_value)Any data type
  • condition: An expression that evaluates to a Boolean
  • true_value: Any data type
  • false_value: Any data type (optional)
Returns true_value if condition is true, otherwise returns false_value. If false_value isn't specified and condition is false, returns null.
nullif(value1, value2)Data type of value1 or null
  • value1, value2: Any data type
Returns null if input value1 equals value2, otherwise returns value1. For example:
  • SELECT nullif(TIMESTAMP '2022-04-06 12:39:25', TIMESTAMP '2022-06-06 12:39:25') returns TIMESTAMP '2022-06-06 12:39:25'
try(expression)null
  • expression
Evaluates an input expression and handles certain types of errors by returning null. These possible errors are handled by try:
  • Division by zero
  • Invalid cast or function argument
  • Numeric value out of range