Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[BUG] replace, trendline and transpose return 500 on a field type they do not support

Đang mở
#5,885 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@cnoramut đang làm issue này rồi.

Từ ngày 21/10/2026.

  • #5903 của @cnoramut — đang mở

Đá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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend

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ả

bug PPL

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 t returns 500 with type CalciteContextException and the message At line 0, column 0: Cannot infer return type for /; operand types: [VARCHAR, DOUBLE].
  • source=cmds | fields host, o | transpose returns 500 with type SQLException and the message Line 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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của opensearch-project/sql

Tất cả issue của opensearch-project/sql

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.