[RFC] Misleading SQL naming in PPL error responses
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- java
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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?
- 主要语言
- Java
- 星标
- 176
- 派生
- 237
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 34
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
opensearch-project/sql 的其他 Issue
-
bug untriaged
难度 2/5 1-3 小时 新手友好度 78/100
opensearch-project/sql#5990 ·
维护者通常 1 天内回复
-
bug untriaged
难度 1/5 1 小时以内 新手友好度 85/100
opensearch-project/sql#5983 ·
维护者通常 1 天内回复
-
[BUG] PromQL queries fail with InvalidTypeIdException when metric has a label named "type"可能已有人在做 @nagendramohan 于 107 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 74/100
opensearch-project/sql#5684 · 4 条评论 ·
维护者通常 1 天内回复
-
[DOC] Calcite settings documentation missing examples可能已有人在做 @AzazelSensei 于 64 天前认领。 未关闭documentation PPL
难度 2/5 1-3 小时 新手友好度 72/100
opensearch-project/sql#4806 · 1 条评论 ·
维护者通常 1 天内回复
-
calcite enhancement Meta performance PPL untriaged
难度 5/5 一周以上 新手友好度 8/100
opensearch-project/sql#5991 ·
维护者通常 1 天内回复
查看 opensearch-project/sql 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 68/100
PCL-Community/PCL-CE#3907 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 2 天内回复
-
area/dependencies area/dependencies/quarkus backport/26.6 backport/26.8 kind/cve severity/critical source/scan-dependencies status/triage
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
docker-to-squash.py: check_dependencies should find mksquashfs on PATH可能已有人在做 @linzch3 今天认领。 未关闭
难度 1/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
chore
难度 1/5 1-3 小时 新手友好度 88/100
lugassawan/swe-workbench#841 ·