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

[BUG] concat, concat_ws, locate, position and truncate return 500 on an argument type they do not support

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

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Start with PPLFuncImpTable.registerOperator and PPLTypeChecker.wrapComposite, where the Calcite operator checkers for concat, concat_ws, locate, position and truncate fail to wrap and become null. Then check CalciteFuncSignature.match, which accepts any argument list when the checker is null. Reproduce with the curl commands in the issue. Done means these five functions return HTTP 400 naming the argument type on the wrong-type fields, as upper does, and existing type-check tests still pass.

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

Descrizione

bug PPL untriaged

Query Information

PPL Command/Query:

source=nums | eval x = concat(f, 'z') | fields x

f is a long field. The concat documentation lists its parameters as strings.

Expected Result: HTTP 400 naming the argument type, as upper(f) on the same field returns.

{
  "error": {
    "context": {
      "stage": "analyzing",
      "stage_description": "Parsing and validating the query"
    },
    "reason": "UPPER function expects {[STRING]}, but got [LONG]",
    "details": "UPPER function expects {[STRING]}, but got [LONG]",
    "location": ["while preparing and validating the query plan"],
    "code": "UNKNOWN",
    "type": "ExpressionEvaluationException"
  },
  "status": 400
}

Actual Result: HTTP 500.

{
  "error": {
    "context": {
      "stage": "executing",
      "stage_description": "Running the query"
    },
    "reason": "Internal error while compiling the query plan.",
    "details": "Line 23, Column 54: Assignment conversion not possible from type \"long\" to type \"java.lang.String\"",
    "location": [
      "while running the query",
      "while compiling the optimized query plan for physical execution"
    ],
    "code": "PLANNING_ERROR",
    "type": "SQLException"
  },
  "status": 500
}

Analysis accepts concat on a long, and the generated Java then fails to compile. The v2 engine, with plugins.calcite.enabled=false, returns HTTP 400 invalid to get stringValue from value of type LONG for the same query.

Five functions return 500 on a wrong type.

Function keyword long double boolean date ip object flat_object nested
concat(f, 'z') 200 500 500 500 200 500 500 500 500
locate('a', f) 200 500 500 500 200 500 500 500 500
truncate(f, 1) 500 200 200 500 500 500 500 500 500
upper(f), for comparison 200 400 400 400 400 400 400 400 400

concat_ws matches the concat row and position matches the locate row.

Dataset Information

Dataset/Schema Type

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

Index Mapping

PUT nums { "mappings": { "properties": { "host": { "type": "keyword" }, "f": { "type": "long" } } } }

Sample Data

POST nums/_doc/1?refresh=true  { "host": "a", "f": 5 }

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

Bug Description

Issue Summary

PPLFuncImpTable.registerOperator wraps each Calcite operator's own operand checker into a PPLTypeChecker through PPLTypeChecker.wrapComposite, which accepts only an OR composition of ImplicitCastOperandTypeChecker rules. All five functions are registered with Calcite checkers outside that shape, so the wrap throws and the checker is set to null. CalciteFuncSignature.match treats a null checker as matching every argument list. The call is then built with no cast, and the mismatch surfaces only in code generation.

Steps to Reproduce

curl -s -XPUT "localhost:9200/nums" -H 'Content-Type: application/json' \
  -d '{"mappings":{"properties":{"host":{"type":"keyword"},"f":{"type":"long"}}}}'
curl -s -XPOST "localhost:9200/nums/_doc/1?refresh=true" -H 'Content-Type: application/json' -d '{"host":"a","f":5}'

# 1. Returns HTTP 500 with a Janino compile error
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
  -d '{"query":"source=nums | eval x = concat(f, '\''z'\'') | fields x"}' -w '\nHTTP %{http_code}\n'

# 2. locate also returns 500, with the reason Failed to prepare the query plan for execution.
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
  -d '{"query":"source=nums | eval x = locate('\''a'\'', f) | fields x"}' -w '\nHTTP %{http_code}\n'

# 3. upper 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=nums | eval x = upper(f) | fields x"}' -w '\nHTTP %{http_code}\n'

Impact

Building a label with concat over a numeric field, such as concat(status_code, ' ', method), returns a 500 reporting an engine defect, with no hint that the field needs a cast. The same holds for locate and position on a number, truncate on a string, and every one of the five on an object, flat_object, ip or boolean field.

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.

Lingua principale
Java
Stelle
175
Fork
232
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.