---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- requires:
    capabilities:
    - method: "POST"
      path: "/_query"
      parameters:
      - "method"
      - "path"
      - "parameters"
      - "capabilities"
      capabilities:
      - "function_stats"
    reason: "META command removed which changes the count of the data returned"
    test_runner_features:
    - "capabilities"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          number_of_shards: 1
        mappings:
          properties:
            data:
              type: "long"
            count:
              type: "integer"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Basic ESQL usage output (telemetry) snapshot version:
- skip:
    awaits_fix: "The number of functions is constantly increasing"
- requires:
    test_runner_features:
    - "capabilities"
    capabilities:
    - method: "POST"
      path: "/_query"
      parameters: []
      capabilities:
      - "snapshot_test_for_telemetry"
      - "fn_byte_length"
      - "match_function_options"
    reason: "Test that should only be executed on snapshot versions"
- do:
    xpack.usage: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    esql.available: true
- match:
    esql.enabled: true
- length:
    esql.features: 22
- set:
    esql.features.dissect: "dissect_counter"
- set:
    esql.features.drop: "drop_counter"
- set:
    esql.features.eval: "eval_counter"
- set:
    esql.features.enrich: "enrich_counter"
- set:
    esql.features.from: "from_counter"
- set:
    esql.features.grok: "grok_counter"
- set:
    esql.features.keep: "keep_counter"
- set:
    esql.features.limit: "limit_counter"
- set:
    esql.features.mv_expand: "mv_expand_counter"
- set:
    esql.features.rename: "rename_counter"
- set:
    esql.features.row: "row_counter"
- set:
    esql.features.show: "show_counter"
- set:
    esql.features.sort: "sort_counter"
- set:
    esql.features.stats: "stats_counter"
- set:
    esql.features.where: "where_counter"
- set:
    esql.features.lookup_join: "lookup_join_counter"
- set:
    esql.features.lookup: "lookup_counter"
- set:
    esql.features.change_point: "change_point_counter"
- set:
    esql.features.inlinestats: "inlinestats_counter"
- set:
    esql.features.rerank: "rerank_counter"
- set:
    esql.features.completion: "completion_counter"
- set:
    esql.features.sample: "sample_counter"
- length:
    esql.queries: 3
- set:
    esql.queries.rest.total: "rest_total_counter"
- set:
    esql.queries.rest.failed: "rest_failed_counter"
- set:
    esql.queries.kibana.total: "kibana_total_counter"
- set:
    esql.queries.kibana.failed: "kibana_failed_counter"
- set:
    esql.queries._all.total: "all_total_counter"
- set:
    esql.queries._all.failed: "all_failed_counter"
- set:
    esql.functions.max: "functions_max"
- set:
    esql.functions.min: "functions_min"
- set:
    esql.functions.cos: "functions_cos"
- set:
    esql.functions.to_long: "functions_to_long"
- set:
    esql.functions.coalesce: "functions_coalesce"
- do:
    esql.query:
      body:
        query: "from test | where data > 2 and to_long(data) > 2 | sort count desc\
          \ | limit 5 | stats m = max(data)"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    xpack.usage: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    esql.available: true
- match:
    esql.enabled: true
- match:
    esql.features.dissect: "$dissect_counter"
- match:
    esql.features.eval: "$eval_counter"
- match:
    esql.features.grok: "$grok_counter"
- gt:
    esql.features.limit: "$limit_counter"
- gt:
    esql.features.sort: "$sort_counter"
- gt:
    esql.features.stats: "$stats_counter"
- gt:
    esql.features.where: "$where_counter"
- match:
    esql.features.lookup_join: "$lookup_join_counter"
- match:
    esql.features.lookup: "$lookup_counter"
- match:
    esql.features.change_point: "$change_point_counter"
- match:
    esql.features.inlinestats: "$inlinestats_counter"
- match:
    esql.features.rerank: "$rerank_counter"
- match:
    esql.features.completion: "$completion_counter"
- match:
    esql.features.sample: "$sample_counter"
- gt:
    esql.queries.rest.total: "$rest_total_counter"
- match:
    esql.queries.rest.failed: "$rest_failed_counter"
- match:
    esql.queries.kibana.total: "$kibana_total_counter"
- match:
    esql.queries.kibana.failed: "$kibana_failed_counter"
- gt:
    esql.queries._all.total: "$all_total_counter"
- match:
    esql.queries._all.failed: "$all_failed_counter"
- gt:
    esql.functions.max: "$functions_max"
- match:
    esql.functions.min: "$functions_min"
- match:
    esql.functions.cos: "$functions_cos"
- gt:
    esql.functions.to_long: "$functions_to_long"
- match:
    esql.functions.coalesce: "$functions_coalesce"
- length:
    esql.functions: 148
---
Basic ESQL usage output (telemetry) non-snapshot version:
- skip:
    awaits_fix: "The number of functions is constantly increasing"
- requires:
    test_runner_features:
    - "capabilities"
    capabilities:
    - method: "POST"
      path: "/_query"
      parameters: []
      capabilities:
      - "non_snapshot_test_for_telemetry"
      - "fn_byte_length"
    reason: "Test that should only be executed on release versions"
- do:
    xpack.usage: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    esql.available: true
- match:
    esql.enabled: true
- length:
    esql.features: 22
- set:
    esql.features.dissect: "dissect_counter"
- set:
    esql.features.drop: "drop_counter"
- set:
    esql.features.eval: "eval_counter"
- set:
    esql.features.enrich: "enrich_counter"
- set:
    esql.features.from: "from_counter"
- set:
    esql.features.grok: "grok_counter"
- set:
    esql.features.keep: "keep_counter"
- set:
    esql.features.limit: "limit_counter"
- set:
    esql.features.mv_expand: "mv_expand_counter"
- set:
    esql.features.rename: "rename_counter"
- set:
    esql.features.row: "row_counter"
- set:
    esql.features.show: "show_counter"
- set:
    esql.features.sort: "sort_counter"
- set:
    esql.features.stats: "stats_counter"
- set:
    esql.features.where: "where_counter"
- set:
    esql.features.lookup_join: "lookup_join_counter"
- set:
    esql.features.lookup: "lookup_counter"
- set:
    esql.features.change_point: "change_point_counter"
- set:
    esql.features.inlinestats: "inlinestats_counter"
- set:
    esql.features.sample: "sample_counter"
- length:
    esql.queries: 3
- set:
    esql.queries.rest.total: "rest_total_counter"
- set:
    esql.queries.rest.failed: "rest_failed_counter"
- set:
    esql.queries.kibana.total: "kibana_total_counter"
- set:
    esql.queries.kibana.failed: "kibana_failed_counter"
- set:
    esql.queries._all.total: "all_total_counter"
- set:
    esql.queries._all.failed: "all_failed_counter"
- set:
    esql.functions.max: "functions_max"
- set:
    esql.functions.min: "functions_min"
- set:
    esql.functions.cos: "functions_cos"
- set:
    esql.functions.to_long: "functions_to_long"
- set:
    esql.functions.coalesce: "functions_coalesce"
- set:
    esql.features.rerank: "rerank_counter"
- set:
    esql.features.completion: "completion_counter"
- do:
    esql.query:
      body:
        query: "from test | where data > 2 and to_long(data) > 2 | sort count desc\
          \ | limit 5 | stats m = max(data)"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    xpack.usage: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    esql.available: true
- match:
    esql.enabled: true
- match:
    esql.features.dissect: "$dissect_counter"
- match:
    esql.features.eval: "$eval_counter"
- match:
    esql.features.grok: "$grok_counter"
- gt:
    esql.features.limit: "$limit_counter"
- gt:
    esql.features.sort: "$sort_counter"
- gt:
    esql.features.stats: "$stats_counter"
- gt:
    esql.features.where: "$where_counter"
- match:
    esql.features.lookup_join: "$lookup_join_counter"
- match:
    esql.features.lookup: "$lookup_counter"
- match:
    esql.features.change_point: "$change_point_counter"
- match:
    esql.features.inlinestats: "$inlinestats_counter"
- match:
    esql.features.rerank: "$rerank_counter"
- match:
    esql.features.completion: "$completion_counter"
- gt:
    esql.queries.rest.total: "$rest_total_counter"
- match:
    esql.queries.rest.failed: "$rest_failed_counter"
- match:
    esql.queries.kibana.total: "$kibana_total_counter"
- match:
    esql.queries.kibana.failed: "$kibana_failed_counter"
- gt:
    esql.queries._all.total: "$all_total_counter"
- match:
    esql.queries._all.failed: "$all_failed_counter"
- gt:
    esql.functions.max: "$functions_max"
- match:
    esql.functions.min: "$functions_min"
- match:
    esql.functions.cos: "$functions_cos"
- gt:
    esql.functions.to_long: "$functions_to_long"
- match:
    esql.functions.coalesce: "$functions_coalesce"
- length:
    esql.functions: 144
