if_else

b when the condition is true, else c (a null condition takes c).

ScalarDeterministic

Flags

Flag Value
Kind scalar
Nulls a null argument gives null
Deterministic yes
Order matters no
Decomposable no

Example

A pipeline from the language's tested corpus that uses if_else, over the example tables.

Hint
from orders
derive {size = if qty > 10 then "big" else if qty > 3 then "mid" else "small", rushed = rush ?? false, a = amount ?? cast(0.00, to: decimal128(10, 2))}

In a plan:

JSON
{
  "args": [
    {
      "args": [
        {
          "col": 3
        },
        {
          "lit": 10,
          "type": {
            "kind": "int64"
          }
        }
      ],
      "fn": "gt"
    },
    {
      "lit": "big",
      "type": {
        "kind": "utf8"
      }
    },
    {
      "args": [
        {
          "args": [
            {
              "col": 3
            },
            {
              "lit": 3,
              "type": {
                "kind": "int64"
              }
            }
          ],
          "fn": "gt"
        },
        {
          "lit": "mid",
          "type": {
            "kind": "utf8"
          }
        },
        {
          "lit": "small",
          "type": {
            "kind": "utf8"
          }
        }
      ],
      "fn": "if_else"
    }
  ],
  "fn": "if_else"
}