[BUG] replace, trendline and transpose return 500 on a field type they do not support
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 32/100
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
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 treturns 500 withtypeCalciteContextExceptionand the messageAt line 0, column 0: Cannot infer return type for /; operand types: [VARCHAR, DOUBLE].source=cmds | fields host, o | transposereturns 500 withtypeSQLExceptionand the messageLine 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
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di opensearch-project/sql
-
[Enhancement] Make the flat_object read depth cap configurable instead of a constantForse già presa @RyanL1997 l’ha presa 9 giorni fa. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
opensearch-project/sql#5842 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] PromQL queries fail with InvalidTypeIdException when metric has a label named "type"Forse già presa @nagendramohan l’ha presa 72 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
opensearch-project/sql#5684 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[DOC] Calcite settings documentation missing examplesForse già presa @AzazelSensei l’ha presa 29 giorni fa. Apertadocumentation PPL
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
opensearch-project/sql#4806 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[RFC] Widen numeric mapping conflicts across indices to one deterministic typeForse già presa @cnoramut l’ha presa 1 giorno fa. Apertauntriaged
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
opensearch-project/sql#5901 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug PPL
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
opensearch-project/sql#5900 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di opensearch-project/sql
Issue simili
-
status: needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
JabRef/jabref#17546 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
hiero-ledger/hiero-sdk-java#3010 ·
I maintainer di solito rispondono entro 1 giorno
-
Optimize consumer version heatmap aggregation to avoid repeated scansForse già presa @praykaria31 l’ha presa oggi. Apertatype/enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Apicurio/apicurio-registry#10662 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
a:false-positive
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
status: waiting-for-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
spring-projects/spring-boot#52347 ·
I maintainer di solito rispondono entro 2 giorni