{
  "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.",
  "type" : "scalar",
  "name" : "case",
  "description" : "Accepts pairs of conditions and values. The function returns the value that\nbelongs to the first condition that evaluates to `true`.\n\nIf the number of arguments is odd, the last argument is the default value which\nis returned when no condition matches. If the number of arguments is even, and\nno condition matches, the function returns `null`.",
  "signatures" : [
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "boolean",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "boolean"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "boolean",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "boolean",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "boolean"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "cartesian_point",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "cartesian_point"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "cartesian_point",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "cartesian_point",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "cartesian_point"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "cartesian_shape",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "cartesian_shape"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "cartesian_shape",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "cartesian_shape",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "cartesian_shape"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "date",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "date"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "date",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "date",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "date"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "date_nanos",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "date_nanos"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "date_nanos",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "date_nanos",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "date_nanos"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "double",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "double"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "double",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "double",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "double"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "geo_point",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "geo_point"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "geo_point",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "geo_point",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "geo_point"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "geo_shape",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "geo_shape"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "geo_shape",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "geo_shape",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "geo_shape"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "integer",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "integer"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "integer",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "integer",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "integer"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "ip",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "ip"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "ip",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "ip",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "ip"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "keyword",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "keyword"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "keyword",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "keyword",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "keyword"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "keyword",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "text",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "keyword"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "long",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "long"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "long",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "long",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "long"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "text",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "keyword"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "text",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "keyword",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "keyword"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "text",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "text",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "keyword"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "unsigned_long",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "unsigned_long"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "unsigned_long",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "unsigned_long",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "unsigned_long"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "version",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        }
      ],
      "variadic" : true,
      "returnType" : "version"
    },
    {
      "params" : [
        {
          "name" : "condition",
          "type" : "boolean",
          "optional" : false,
          "description" : "A condition."
        },
        {
          "name" : "trueValue",
          "type" : "version",
          "optional" : false,
          "description" : "The value that’s returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
        },
        {
          "name" : "elseValue",
          "type" : "version",
          "optional" : true,
          "description" : "The value that’s returned when no condition evaluates to `true`."
        }
      ],
      "variadic" : true,
      "returnType" : "version"
    }
  ],
  "examples" : [
    "FROM employees\n| EVAL type = CASE(\n    languages <= 1, \"monolingual\",\n    languages <= 2, \"bilingual\",\n     \"polyglot\")\n| KEEP emp_no, languages, type",
    "FROM sample_data\n| EVAL successful = CASE(\n    STARTS_WITH(message, \"Connected to\"), 1,\n    message == \"Connection error\", 0\n  )\n| STATS success_rate = AVG(successful)",
    "FROM sample_data\n| EVAL error = CASE(message LIKE \"*error*\", 1, 0)\n| EVAL hour = DATE_TRUNC(1 hour, @timestamp)\n| STATS error_rate = AVG(error) by hour\n| SORT hour"
  ],
  "preview" : false,
  "snapshot_only" : false
}
