[BUG] replace, trendline and transpose return 500 on a field type they do not support
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 32/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 175
- Fork
- 233
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 39
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của opensearch-project/sql
-
[Enhancement] Make the flat_object read depth cap configurable instead of a constantCó thể đã có người làm @RyanL1997 đã nhận 12 ngày trước. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
opensearch-project/sql#5842 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] PromQL queries fail with InvalidTypeIdException when metric has a label named "type"Có thể đã có người làm @nagendramohan đã nhận 74 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
opensearch-project/sql#5684 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[DOC] Calcite settings documentation missing examplesCó thể đã có người làm @AzazelSensei đã nhận 31 ngày trước. Đang mởdocumentation PPL
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
opensearch-project/sql#4806 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement untriaged
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 54/100
opensearch-project/sql#5906 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug PPL untriaged
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
opensearch-project/sql#5904 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của opensearch-project/sql
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
[Bug]: REST API URL starting with "http" but no scheme (e.g. httpbin.org/get) is not given an http:// prefixCó thể đã có người làm @ItsDeadlyProgrammer đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
appsmithorg/appsmith#42471 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
code-maintenance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
bug priority: medium Review effort [1-5]: 3 status: needs-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
carlos-emr/carlos#5258 ·
Maintainer thường phản hồi trong vòng 1 ngày