Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[BUG] replace, trendline and transpose return 500 on a field type they do not support

Aperta
#5,885 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@cnoramut ci sta già lavorando.

Dal 21/10/2026.

  • #5903 di @cnoramut — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
32/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
backend

Direzione di ricerca

Start with CalciteRelNodeVisitor, where the replace, trendline and transpose expressions are built without an operand type check, and compare with how PPLFuncImpTable.resolve validates argument types for eval functions. Then read SyncErrorReportRenderer.isClientError to see why CalciteContextException and the compile SQLException map to 500. Done means the failing cells in the matrix return 400 naming the field and its type, with the existing replace() 400 as the model.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug PPL

Query Information

PPL Command/Query:

source=cmds | replace "a" WITH "b" IN n | fields n

n is a long field. The replace documentation describes the command as replacing text.

Expected Result: HTTP 400 naming the field and its type. The replace() function on the same field already returns a 400 that names the type, REPLACE function expects {[STRING,STRING,STRING]}, but got [LONG,STRING,STRING].

Actual Result: HTTP 500.

{
  "error": {
    "context": {
      "stage": "executing",
      "stage_description": "Running the query"
    },
    "reason": "Internal error while compiling the query plan.",
    "details": "Line 22, Column 112: No applicable constructor/method found for actual parameters \"long, java.lang.String, java.lang.String, boolean\"; candidates are: \"public static java.lang.String org.apache.calcite.runtime.SqlFunctions.replace(java.lang.String, java.lang.String, java.lang.String, boolean)\"",
    "location": [
      "while running the query",
      "while compiling the optimized query plan for physical execution"
    ],
    "code": "PLANNING_ERROR",
    "type": "SQLException"
  },
  "status": 500
}

trendline on a keyword field and transpose over an object field also return 500 on the same index.

  • source=cmds | trendline sma(2, s) as t | fields t returns 500 with type CalciteContextException and the message At line 0, column 0: Cannot infer return type for /; operand types: [VARCHAR, DOUBLE].
  • source=cmds | fields host, o | transpose returns 500 with type SQLException and the message Line 138, Column 63: Cannot cast "java.util.Map" to "java.lang.String".

Each cell below is a single index per type, and f stands for a field of the column's type.

Command keyword long double boolean date ip object flat_object nested
replace "a" WITH "b" IN f 200 500 500 500 200 500 500 500 500
trendline sma(2, f) as t 500 200 200 500 500 400 500 500 500
fields host, f | transpose 200 200 200 200 200 200 500 500 500

Dataset Information

Dataset/Schema Type

  • OpenTelemetry (OTEL)
  • Simple Schema for Observability (SS4O)
  • Open Cybersecurity Schema Framework (OCSF)
  • Custom (details below)

Index Mapping

PUT cmds { "mappings": { "properties": { "host": { "type": "keyword" }, "n": { "type": "long" }, "s": { "type": "keyword" }, "o": { "properties": { "a": { "type": "keyword" } } } } } }

Sample Data

POST cmds/_doc/1?refresh=true  { "host": "a", "n": 5, "s": "abc", "o": { "a": "x" } }
POST cmds/_doc/2?refresh=true  { "host": "b", "n": 7, "s": "abd", "o": { "a": "y" } }

A single index reproduces it. No mapping conflict is involved.

Bug Description

Issue Summary

Each of the three commands builds its Calcite expression directly in CalciteRelNodeVisitor and never checks the operand type. Function calls in eval go through PPLFuncImpTable.resolve, which checks the argument types of any function registered with a checker and returns a 400. These commands do not use it, so the mismatch surfaces later, either in Calcite's return type inference or in Janino. SyncErrorReportRenderer.isClientError does not map CalciteContextException or the SQLException from a failed compile to 400, so both return 500.

Steps to Reproduce

curl -s -XPUT "localhost:9200/cmds" -H 'Content-Type: application/json' \
  -d '{"mappings":{"properties":{"host":{"type":"keyword"},"n":{"type":"long"},"s":{"type":"keyword"},"o":{"properties":{"a":{"type":"keyword"}}}}}}'
curl -s -XPOST "localhost:9200/cmds/_doc/1?refresh=true" -H 'Content-Type: application/json' -d '{"host":"a","n":5,"s":"abc","o":{"a":"x"}}'
curl -s -XPOST "localhost:9200/cmds/_doc/2?refresh=true" -H 'Content-Type: application/json' -d '{"host":"b","n":7,"s":"abd","o":{"a":"y"}}'

# 1. replace on a long returns HTTP 500
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
  -d '{"query":"source=cmds | replace \"a\" WITH \"b\" IN n | fields n"}' -w '\nHTTP %{http_code}\n'

# 2. trendline on a keyword returns HTTP 500
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
  -d '{"query":"source=cmds | trendline sma(2, s) as t | fields t"}' -w '\nHTTP %{http_code}\n'

# 3. transpose over an object returns HTTP 500
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
  -d '{"query":"source=cmds | fields host, o | transpose"}' -w '\nHTTP %{http_code}\n'

# 4. The replace() function on the same field is checked and returns HTTP 400
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
  -d '{"query":"source=cmds | eval x = replace(n, '\''a'\'', '\''b'\'') | fields x"}' -w '\nHTTP %{http_code}\n'

Impact

Each of these is a user mistake that the engine reports as its own defect, with a 500, a Java or SQL type name in details, and nothing about which field or type to change.

Environment Information

OpenSearch Version: main at 4d9839398, 3.10.0-SNAPSHOT, one node, with the defaults plugins.calcite.enabled=true, plugins.calcite.pushdown.enabled=true and plugins.calcite.fallback.allowed=false.

Additional Details:

  • #5753 set the goal that a Janino failure never reaches a user, and that each reachable trigger gets an input-level guard.
Lingua principale
Java
Stelle
175
Fork
233
Merge medio
3g 3h
PR unite (30g)
42

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di opensearch-project/sql

Tutte le issue di opensearch-project/sql

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.