Skip to content

[BUG] bin with bins parameter fails on field @timestamp #4317

Closed

Description

@qianheng-aws

*What is the bug?
bin command supports different parameters like span, bins...

It works fine when using bin on @timestamp with parameter span:

source=events | bin @timestamp span=3m

But got failure when using parameter bins:

source=events | bin @timestamp bins=3

it gets error:

{
  "error": {
    "reason": "There was internal problem at backend",
    "details": "java.sql.SQLException: Error while preparing plan [LogicalSystemLimit(fetch=[10000], type=[QUERY_SIZE_LIMIT])\n  LogicalProject(host=[$0], cpu_usage=[$2], region=[$3], @timestamp=[WIDTH_BUCKET($1, 3, -(MAX($1) OVER (), MIN($1) OVER ()), MAX($1) OVER ())])\n    CalciteLogicalIndexScan(table=[[OpenSearch, events]])\n]",
    "type": "RuntimeException"
  },
  "status": 500
}

and the stracktrace in the backend log:

Suppressed: java.lang.RuntimeException: while resolving method 'minus[class java.lang.String, class java.lang.String]' in class class org.apache.calcite.runtime.SqlFunctions
                at org.apache.calcite.linq4j.tree.Types.lookupMethod(Types.java:297) ~[?:?]
                at org.apache.calcite.linq4j.tree.Expressions.call(Expressions.java:453) ~[?:?]
                at org.apache.calcite.adapter.enumerable.RexImpTable$BinaryImplementor.implementSafe(RexImpTable.java:3197) ~[?:?]
...
...

How can one reproduce the bug?
Steps to reproduce the behavior:

  1. Add logs:
POST localhost:9200/events/_bulk/
{"index":{"_id":"1"}}
{"@timestamp":"2024-07-01T00:00:00","host":"web-01","cpu_usage":45.2,"region":"us-east"}
{"index":{"_id":"2"}}
{"@timestamp":"2024-07-01T00:01:00","host":"web-02","cpu_usage":38.7,"region":"us-west"}
{"index":{"_id":"3"}}
{"@timestamp":"2024-07-01T00:02:00","host":"web-01","cpu_usage":55.3,"region":"us-east"}
{"index":{"_id":"4"}}
{"@timestamp":"2024-07-01T00:03:00","host":"db-01","cpu_usage":42.1,"region":"eu-west"}
{"index":{"_id":"5"}}
{"@timestamp":"2024-07-01T00:04:00","host":"web-02","cpu_usage":41.8,"region":"us-west"}
  1. Enable calcite
PUT localhost:9200/_plugins/_query/settings
{
    "transient": {
        "plugins.calcite.enabled": true,
        "plugins.calcite.pushdown.enabled": true,
        "plugins.calcite.fallback.allowed": false   
    }
}
  1. Query with above failed PPL and got error.

What is your host/environment?

  • OS: MacOS
  • Version 3.2.0
  • Plugins

Do you have any screenshots?
If applicable, add screenshots to help explain your problem.

Do you have any additional context?
Add any other context about the problem.

Activity

  1. added
    bug
    PPL
    calcite
    on Sep 17, 2025
  2. self-assigned this
    on Sep 22, 2025
  3. moved this from Not Started to Done in PPL Trackeron Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

PPLbugcalcite

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions