[BUG] sort, stats max, and stats min on an object or nested field return 500
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
Start with AbstractCalciteIndexScan.pushDownSort and AggregateAnalyzer, then trace how BackgroundSearchScanner and RestPPLQueryAction handle the shard error; reproduce using the supplied mapping and PPL queries. Done means sort and stats max/min on object or nested fields no longer surface as HTTP 500, with behavior matching the expected 400 or pushdown-off results.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Query Information
PPL Command/Query:
source=logs_a | sort f
f is an object field, which PPL reports as struct. The same 500 comes back when f is nested, geo_point or flat_object.
Expected Result: HTTP 400 naming the field and its type. The v2 engine, with plugins.calcite.enabled=false, returns 400 for sort f on all four types.
Actual Result: HTTP 500.
{
"error": {
"context": {
"stage": "executing",
"stage_description": "Running the query"
},
"reason": "java.sql.SQLException: exception while executing query: Failed to fetch data from the index: the background task failed or interrupted.\n Inner error: Failed to execute phase [query], all shards failed; shardFailures {[sKGeDUTgTzGvZ14nx-1U0g][logs_a][0]: RemoteTransportException[[80a9971e0936][127.0.0.1:9310][indices:data/read/search[phase/query]]]; nested: QueryShardException[No mapping found for [f] in order to sort on]; }",
"details": "java.sql.SQLException: exception while executing query: Failed to fetch data from the index: the background task failed or interrupted.\n Inner error: Failed to execute phase [query], all shards failed; shardFailures {[sKGeDUTgTzGvZ14nx-1U0g][logs_a][0]: RemoteTransportException[[80a9971e0936][127.0.0.1:9310][indices:data/read/search[phase/query]]]; nested: QueryShardException[No mapping found for [f] in order to sort on]; }",
"location": ["while running the query"],
"code": "UNKNOWN",
"type": "RuntimeException"
},
"status": 500
}
Every sort on f returns 500 for all four types.
| Query | object |
nested |
geo_point |
flat_object |
|---|---|---|---|---|
sort f |
500 | 500 | 500 | 500 |
sort - f |
500 | 500 | 500 | 500 |
sort f | head 1 |
500 | 500 | 500 | 500 |
sort f | reverse |
500 | 500 | 500 | 500 |
fields f |
200 | 200 | 200 | 200 |
Each 500 carries a shard error that the same sort, sent to _search directly as {"sort":[{"f":{"order":"asc","missing":"_first"}}]}, returns as HTTP 400.
f |
Direct _search |
|---|---|
object |
400, No mapping found for [f] in order to sort on |
nested |
400, No mapping found for [f] in order to sort on |
geo_point |
400, can't sort on geo_point field without using specific sorting feature, like geo_distance |
flat_object |
400, Field [f] of type [flat_object] does not support doc_value in root field |
Over a wildcard sort f also returns 500 when f is object in every index, when it is object in one index and nested in another, and when the other indices do not map it.
Dataset Information
Dataset/Schema Type
- OpenTelemetry (OTEL)
- Simple Schema for Observability (SS4O)
- Open Cybersecurity Schema Framework (OCSF)
- Custom (details below)
Index Mapping
PUT logs_a { "mappings": { "properties": { "host": { "type": "keyword" }, "f": { "properties": { "code": { "type": "keyword" } } } } } }
The other three types use the same index with f mapped as { "type": "nested", "properties": { "code": { "type": "keyword" } } }, { "type": "geo_point" } or { "type": "flat_object" }.
Sample Data
POST logs_a/_doc/1?refresh=true { "host": "a", "f": { "code": "USD" } }
The geo_point index holds { "lat": 2, "lon": 2 } and the nested index holds [ { "code": "USD" } ]. source=logs_a | fields f returns 200 for all four, so reading the field works.
Bug Description
Issue Summary
OpenSearch cannot sort on any of these four types, and the shard rejects such a sort with a 400. An object field has an ObjectMapper but no MappedFieldType, so FieldSortBuilder.resolveUnmappedType throws QueryShardException, while geo_point and the root of a flat_object throw IllegalArgumentException. PPL plans sort f without checking the field type, and AbstractCalciteIndexScan.pushDownSort pushes it as a field sort. BackgroundSearchScanner.getCurrentResponse, Avatica, OpenSearchExecutionEngine and StageErrorHandler wrap the SearchPhaseExecutionException in turn, so RestPPLQueryAction.getRawErrorCode, which unwraps only the ErrorReport, finds a RuntimeException and returns 500.
Steps to Reproduce
curl -s -XPUT "localhost:9200/logs_a" -H 'Content-Type: application/json' \
-d '{"mappings":{"properties":{"host":{"type":"keyword"},"f":{"properties":{"code":{"type":"keyword"}}}}}}'
curl -s -XPOST "localhost:9200/logs_a/_doc/1?refresh=true" -H 'Content-Type: application/json' -d '{"host":"a","f":{"code":"USD"}}'
# 1. sort on the object field returns HTTP 500
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
-d '{"query":"source=logs_a | sort f"}' -w '\nHTTP %{http_code}\n'
# 2. The sort that PPL pushes, sent as a raw search, returns HTTP 400
curl -s -XPOST "localhost:9200/logs_a/_search" -H 'Content-Type: application/json' \
-d '{"sort":[{"f":{"order":"asc","missing":"_first"}}]}' -w '\nHTTP %{http_code}\n'
# 3. A geo_point field returns HTTP 500 the same way
curl -s -XPUT "localhost:9200/logs_g" -H 'Content-Type: application/json' \
-d '{"mappings":{"properties":{"host":{"type":"keyword"},"f":{"type":"geo_point"}}}}'
curl -s -XPOST "localhost:9200/logs_g/_doc/1?refresh=true" -H 'Content-Type: application/json' -d '{"host":"a","f":{"lat":2,"lon":2}}'
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
-d '{"query":"source=logs_g | sort f"}' -w '\nHTTP %{http_code}\n'
Impact
A sort on an object, nested, geo_point or flat_object field, alone or followed by head or reverse, returns a 500 whose message names an OpenSearch shard failure and a node address. A client cannot tell that request apart from a server fault, and a retry fails the same way.
Environment Information
OpenSearch Version: main at c640cb921, 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:
No open or closed issue tracks this.
- Lenguaje dominante
- Java
- Estrellas
- 175
- Forks
- 236
- Merge medio
- 2 d 15 h
- PR fusionados (30 d)
- 41
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de opensearch-project/sql
-
[BUG] PromQL queries fail with InvalidTypeIdException when metric has a label named "type"Posiblemente ocupada @nagendramohan la tomó hace 87 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
opensearch-project/sql#5684 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
[DOC] Calcite settings documentation missing examplesPosiblemente ocupada @AzazelSensei la tomó hace 44 días. Abiertodocumentation PPL
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
opensearch-project/sql#4806 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
opensearch-project/sql#5928 ·
Los mantenedores suelen responder en 1 día
-
[Testing] Test downstream plugins that load SQL classes (alerting, skills)Posiblemente ocupada @ahkcs la tomó hace 2 días. Abiertoinfrastructure testing
Dificultad 5/5 Más de una semana Aptitud para principiantes 18/100
opensearch-project/sql#5925 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[BUG] Analytics routing does not resolve aliases and wildcard index expressionsPosiblemente ocupada @KarstenSchnitter la tomó hace 7 días. Abiertoanalytic-engine bug
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
opensearch-project/sql#5916 ·
Los mantenedores suelen responder en 1 día
Todos los issues de opensearch-project/sql
Issues similares
-
Good First Issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
hiero-ledger/hiero-sdk-java#3044 ·
Los mantenedores suelen responder en 1 día
-
A second build without clean fails in resources-optimizer-maven-plugin because minified files are minified againPosiblemente ocupada @papegaaij la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
hermes-queue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
chrisalunlloyd2-sudo/mindpalace#337 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
[Regression][98.0.0] Android I/flutter logs are automatically folded by FlutterConsoleFoldingAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
flutter/flutter-intellij#9221 ·
Los mantenedores suelen responder en 1 día