[RFC] Misleading SQL naming in PPL error responses
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- java
- Ambito
- backend-api-design
Direzione di ricerca
Read the error response examples and the discussion of the two proposed parts: cleaning up the JDBC wrapper and choosing a stable client classification field. The issue is an open RFC with unresolved questions about client compatibility and error behavior, so a contributor should first help settle the desired contract. Done would mean an agreed approach that defines the response fields and their compatibility expectations.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem Statement
The problem. PPL error responses can identify a failure as a SQL exception, even though the user wrote PPL. More broadly, they show names from the engine's implementation rather than terms that describe the failure.
Why it matters. Users, support engineers and client tools can all be misled about what failed and who should act. A mistake in the query can look like a failure in a SQL engine.
The gap, from PPL's side. The error response has no public vocabulary of its own. Its main classifier is the name of whichever Java exception reaches the response, and the language-neutral alternative covers only some failures. We need to decide what clients should rely on and how much of today's response can change.
Current State
SQL and PPL share one plugin and much of their error-handling code.
typeis a Java class name. It was not designed as a public name, but clients already read it and some match specific values.codeis the language-neutral field. It came from the work under #4919 and #5261, but many common failures, including syntax and shard-level errors, have no specific code.- The real cause can be buried. Engine wrapper text can appear ahead of the actual reason, so a query mistake reads like an engine failure.
- Not every consumer reads the response. Some plugins call PPL over transport and receive the exception directly.
"SQL" reaches users from three places:
| Source of the name | Who sees it | Accurate? |
|---|---|---|
| SQL-named classes in the legacy engine | SQL users | Yes |
java.sql.SQLException from the JDBC layer under Calcite |
PPL users | No, it refers to JDBC rather than the SQL language |
Infrastructure names such as the sql-worker thread pool |
SQL and PPL users | It is the real name, but reads as SQL-specific to PPL users |
On the default route, Calcite serves only PPL, so PPL users see java.sql.SQLException and SQL users do not.
Long-Term Goals
- PPL errors describe the failure in the user's terms, not in terms of the engine's internals.
- Clients and tools have one documented, language-neutral field to classify errors.
- Existing clients are not broken without notice.
Proposal
Initial proposal, open for discussion. It combines one option from each part of the comparison below:
- Clean up the error before returning it, so PPL responses show the real cause instead of the JDBC wrapper.
- Make
codethe stable field: fill it in for common failures and document it as the field to rely on. - Document the error fields: which ones are stable, and that
typeis for diagnostics.
This leaves the engine's own error handling unchanged, and keeps today's type values for every failure that is not an engine wrapper.
Approach
The problem has two independent parts, and the proposal picks one option from each. All options below use the same running example.
Running example
source=logs | sort user, where user is an object field. OpenSearch cannot sort on an object field, so the mistake is in the query. Today PPL returns:
{
"status": 400,
"error": {
"type": "RuntimeException",
"code": "UNKNOWN",
"reason": "java.sql.SQLException: exception while executing query: Failed to fetch data from the index: the background task failed or interrupted. Inner error: Failed to execute phase [query], all shards failed; ... QueryShardException[No mapping found for [user] in order to sort on]"
}
}
The user's actual mistake is only at the very end. Everything before it is engine internals, and it starts with a SQL exception.
Part 1: What users read
The engine runs PPL through a JDBC layer. That layer wraps failures in java.sql.SQLException, which can hide the real cause.
| Option | What changes | Pros | Cons | Client impact |
|---|---|---|---|---|
| Explain it in the docs | Nothing in the response; the docs explain the name | No risk | Users still see the misleading name | None |
| Clean up the error before returning it | The response shows the real cause instead of the wrapper | Fixes what users see; engine logic is untouched | Plugins that call PPL directly, such as Alerting, still get the old text | Medium |
| Clean up the error where it is thrown | The engine stops passing the wrapper up | Also fixes plugins that call PPL directly | Engine logic depends on these wrappers today, so regressions are likely | Medium for clients, high for the engine |
How each option changes the running example:
- Explain it in the docs. The response stays as above. The docs gain a note such as: "
java.sql.SQLExceptionin a PPL error comes from the JDBC layer the engine runs on. It does not mean your query was run as SQL." - Clean up the error before returning it. The response becomes (illustrative):
{ "type": "SearchPhaseExecutionException", "reason": "No mapping found for [user] in order to sort on" } - Clean up the error where it is thrown. The response is the same as with the previous option. The difference is for plugins such as Alerting that call PPL directly: they receive the exception rather than the response. Today that exception's message starts with
java.sql.SQLException: exception while executing query, and only this option changes it.
Part 2: What tools rely on
| Option | What changes | Pros | Cons | Client impact |
|---|---|---|---|---|
Make code the stable field |
Common failures get a specific code, and the docs name it as the field to rely on |
Additive; breaks no client | Ongoing work; type keeps exposing class names |
Low |
Redefine type |
type carries designed, language-neutral names instead of class names |
One clean field | Breaks clients that match today's values; may need a major version | High |
Two PPL errors today:
reason |
type |
code |
|---|---|---|
Field [usr] not found. |
IllegalArgumentException |
FIELD_NOT_FOUND |
Rex pattern must contain at least one named capture group |
IllegalArgumentException |
UNKNOWN |
- Make
codethe stable field. A tool can tell these two errors apart bycode, but not bytype. The work is to fill incodewherever it is missing orUNKNOWN. That includes the running example and syntax errors, which today have nocodeat all. - Redefine
type. The first error'stypewould become a designed name such asFieldNotFound. Clients that match today's values break. For example, the Traces view in OpenSearch Dashboards detects a missing field by checkingtype === "SemanticCheckException".
Client impact is based on public OpenSearch repositories. Private integrations are unknown, so feedback from those users is especially welcome.
Alternative
Besides the options compared above, two more were considered. Neither solves the problem:
- Rename our Java exceptions. The misleading name is the JDK's
java.sql.SQLException, which we cannot rename. Renaming our own classes, such asSqlParseException, would not change the running example at all, and those classes only reach SQL users, where the name is accurate. - Add a
languagefield. The running example would gain"language": "ppl", but itsreasonwould still start withjava.sql.SQLException.
Implementation Discussion
- Plugins that call PPL directly. Should they also get the cleaned-up error? That needs the error cleaned up where it is thrown, or a change on their side.
- Stability of
type. Shouldtypebe documented as unstable, or should today's values be kept as they are, apart from the engine wrappers? - Existing dependence. Does anyone match on the engine wrapper text, or on
typevalues such asRuntimeException?
- Lingua principale
- Java
- Stelle
- 176
- Fork
- 237
- Merge medio
- 2g 12h
- PR unite (30g)
- 34
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
-
bug untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
opensearch-project/sql#5990 ·
I maintainer di solito rispondono entro 1 giorno
-
bug untriaged
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
opensearch-project/sql#5983 ·
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 107 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 64 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
-
calcite enhancement Meta performance PPL untriaged
Difficoltà 5/5 Più di una settimana Idoneità per principianti 8/100
opensearch-project/sql#5991 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di opensearch-project/sql
Issue simili
-
NeoForge 安装任务的子任务描述有误Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
PCL-Community/PCL-CE#3907 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 2 giorni
-
area/dependencies area/dependencies/quarkus backport/26.6 backport/26.8 kind/cve severity/critical source/scan-dependencies status/triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
docker-to-squash.py: check_dependencies should find mksquashfs on PATHForse già presa @linzch3 l’ha presa oggi. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
chore
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
lugassawan/swe-workbench#841 ·