Skip to content

[BUG] bin with stats command throw exception #4322

@penghuo

Description

@penghuo

What is the bug?
A clear and concise description of the bug.

How can one reproduce the bug?

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

{
  "query": "search source=log* | bin @timestamp span=5m | stats count by @timestamp"
}

{
  "error": {
    "reason": "Error occurred in OpenSearch engine: all shards failed",
    "details": "Shard[0]: org.opensearch.sql.exception.ExpressionEvaluationException: invalid to get doubleValue from value of type STRING\n\nFor more details, please send request for Json format to see the raw response from OpenSearch engine.",
    "type": "SearchPhaseExecutionException"
  },
  "status": 500
}

What is the expected behavior?
no exception, results is same as

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

{
  "query": "search source=log* | stats count by span(@timestamp, 5m)"
}

{
...
  "datarows": [
    [
      1,
      "2025-09-04 16:15:00"
    ]
  ],
...
}

Do you have any additional context?

### 1 create index template
POST {{baseUrl}}/_index_template/log-template
Content-Type: application/x-ndjson

{
  "index_patterns": ["logs-*"],
  "priority": 100,
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 1
    },
    "mappings": {
      "dynamic_templates": [
        {
          "resource_attributes": {
            "path_match": "resource.attributes.*",
            "mapping": { "type": "keyword" },
            "match_mapping_type": "string"
          }
        },
        {
          "attributes": {
            "path_match": "attributes.*",
            "mapping": { "type": "keyword" },
            "match_mapping_type": "string"
          }
        }
      ],
      "properties": {
        "traceId": { "type": "keyword" },
        "flags": { "type": "byte" },
        "severityNumber": { "type": "integer" },
        "body": {"norms": false, "type": "text"},
        "serviceName": { "type": "keyword" },
        "schemaUrl": { "type": "keyword" },
        "spanId": { "type": "keyword" },
        "@timestamp": { "type": "date" },
        "severityText": { "type": "keyword" },
        "@version": { "type": "keyword" },
        "attributes": {
          "type": "object",
          "properties": {
            "time": { "enabled": false, "type": "object" }
          }
        },
        "time": { "type": "date" },
        "observedTimestamp": { "type": "date" }
      }
    }
  }
}

### create index
PUT {{baseUrl}}/log-00001

### index doc
POST {{baseUrl}}/log-00001/_doc
Content-Type: application/x-ndjson

{
    "traceId": "",
    "instrumentationScope": {
        "droppedAttributesCount": 0
    },
    "resource": {
        "droppedAttributesCount": 0,
        "attributes": {
            "log_type": "EKS_node",
            "k8s_label.productid": "pr123456",
            "k8s_label.sourcetype": "unknown",
            "productid": "pr123456",
            "k8s.platform": "EKS",
            "k8s_label.criticality_code": "99",
            "k8s.cluster.business.unit": "bu",
            "criticality_code": "5",
            "sourcetype": "unknown",
            "log_tier": "standard",
            "applicationid": "ap123456",
            "obs_namespace": "defaultv1"
        },
        "schemaUrl": ""
    },
    "flags": 0,
    "severityNumber": 0,
    "schemaUrl": "",
    "spanId": "",
    "severityText": "",
    "attributes": {
        "cluster.name": "xyz-cluster1-ci-prod-us-east-1",
        "cluster.region": "us-east-1",
        "log.file.path": "/var/log/xyz/abc.log",
        "cluster.env": "prod",
        "obs_body_length": 146
    },
    "time": "2025-09-04T16:17:36.046227585Z",
    "droppedAttributesCount": 0,
    "observedTimestamp": "2025-09-04T16:17:36.046227585Z",
    "@timestamp": "2025-09-04T16:17:39.133Z",
    "body": "{\"msg\":\"Error finding unassigned IPs for ENI xyz\",\"caller\":\"xyz/abc.go:702\",\"level\":\"error\",\"ts\":\"2025-09-04T16:17:35.976Z\"}"
}

Metadata

Metadata

Assignees

Labels

PPLPiped processing languagebugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions