Skip to content

[BUG] Parsing fails after aggregation when field types are transformed to non-numeric strings #4115

@ahkcs

Description

@ahkcs

What is the bug?
When operations transform numeric fields to produce non-numeric string values (e.g., "30-40", "20-25"), the response parser fails. The aggregation itself executes correctly in OpenSearch, but parsing the response fails because the parser uses type information that is not updated.

How can one reproduce the bug?
This issue affects multiple operations that transform field types:

Example 1: bin command produces range strings

  curl -X POST "localhost:9200/_plugins/_ppl" \
    -H "Content-Type: application/json" \
    -d '{"query":"source=accounts | bin age span=10 | stats count() by age"}'
  Error: For input string: "30-40"

Example 2: eval with string concatenation

  curl -X POST "localhost:9200/_plugins/_ppl" \
    -H "Content-Type: application/json" \
    -d '{"query":"source=accounts | eval age = CAST(age AS STRING) + \"-25\" | stats count() by age | head 3"}'
  Error: For input string: "20-25"

Both fail with:

  {
    "error": {
      "reason": "There was internal problem at backend",
      "details": "java.sql.SQLException: exception while executing query: For input string: \"20-25\"",
      "type": "RuntimeException"
    },
    "status": 500
  }

What is the expected behavior?
Expected for bin command:

  {
    "schema": [
      {"name": "count()", "type": "bigint"},
      {"name": "age", "type": "string"}
    ],
    "datarows": [
      [451, "20-30"],
      [504, "30-40"],
      [45, "40-50"]
    ]
  }

Expected for eval with concatenation:

  {
    "schema": [
      {"name": "count()", "type": "bigint"},
      {"name": "age", "type": "string"}
    ],
    "datarows": [
      [44, "20-25"],
      [46, "21-25"],
      [51, "22-25"]
    ]
  }

Do you have any additional context?

  • This issue was initially discovered with the bin command but affects any operation that transforms field types to produce non-numeric strings
  • The extendTypeMapping method uses putIfAbsent which was designed to prevent overwriting field types

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