Skip to content

ESQL: Aggregations for Null columns are not handled correctly  #104430

@qn895

Description

@qn895

Elasticsearch Version

8.11

Installed Plugins

No response

Java Version

bundled

OS Version

Darwin Kernel Version 22.6.0

Problem Description

ESQL aggregations should return values for null columns, but currently it's throwing an error:

POST _query
{"query":"""ROW a = 1, b = "two", c = null
| STATS `a_count` = COUNT(`a`), `a_cardinality` = COUNT_DISTINCT(`a`),`b_count` = COUNT(`b`), `b_cardinality` = COUNT_DISTINCT(`b`),`c_count` = COUNT(`c`), `c_cardinality` = COUNT_DISTINCT(`c`)"""}

Error:

#! No limit defined, adding default limit of [500]
{
  "error": {
    "root_cause": [
      {
        "type": "esql_illegal_argument_exception",
        "reason": "unknown agg: class org.elasticsearch.xpack.ql.expression.Literal: null"
      }
    ],
    "type": "esql_illegal_argument_exception",
    "reason": "unknown agg: class org.elasticsearch.xpack.ql.expression.Literal: null"
  },
  "status": 500
}

Steps to Reproduce

Run the following query:

POST _query
{"query":"""ROW a = 1, b = "two", c = null
| STATS `a_count` = COUNT(`a`), `a_cardinality` = COUNT_DISTINCT(`a`),`b_count` = COUNT(`b`), `b_cardinality` = COUNT_DISTINCT(`b`),`c_count` = COUNT(`c`), `c_cardinality` = COUNT_DISTINCT(`c`)"""}

Logs (if relevant)

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions