Skip to content

[BUG] stats command throw exception when alias of metrics with existing column name #4192

@penghuo

Description

@penghuo

What is the bug?
stats command throw exception when alias of metrics with existing column name.

How can one reproduce the bug?

###
PUT {{baseUrl}}/log00001
Content-Type: application/x-ndjson

{
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "age": {
        "type": "integer"
      }
    }
  }
}

###
GET {{baseUrl}}/log00001

###
POST {{baseUrl}}/log00001/_bulk
Content-Type: application/x-ndjson

{ "index": { "_id": 1 } }
{"@timestamp":"2025-08-19T04:53:24Z", "age":10}
{ "index": { "_id": 2 } }
{"@timestamp":"2025-08-20T04:53:24Z", "age":11}

###
POST {{baseUrl}}/_plugins/_ppl/
Content-Type: application/x-ndjson

{
  "query": "source=log00001 | stats sum(age) as age by span(@timestamp, 1d)"      --> age is existing column name
}

{
  "error": {
    "reason": "There was internal problem at backend",
    "details": "class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap')",
    "type": "ClassCastException"
  },
  "status": 500
}

What is the expected behavior?
A clear and concise description of what you expected to happen.

Metadata

Metadata

Assignees

Labels

PPLPiped processing languagebugSomething isn't workingerror-experienceIssues related to how we handle failure cases in the plugin.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions