Switch per-name field lookups to RelBuilder.fields once future Calcite patch includes CALCITE-7953
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue nà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
- 48/100
- Loại issue
- Tái cấu trúc
- Độ 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, performance
Hướng nghiên cứu
All open sites live in core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java: dropStructChildrenFor, visitTranspose, visitFlatten and buildAddRowTotalAggregate. First check the Calcite version at build.gradle line 55 — the rewrite is only valid once it includes CALCITE-7953 (1.43.0), otherwise resolve fields by position as convert/replace did. Benchmark with a CalcitePPLAbstractTest subclass modelled on CalcitePPLWideNestedSchemaTest; done means identical plans and linear scaling in the appendix's queries.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Several PPL commands resolve many fields by name with one RelBuilder.field(String) call per name. Each call scans the input's fields, so with n fields and m names the analyze phase takes O(n·m) time: up to 6 s at 20,000 fields (see the appendix).
CALCITE-7953 (apache/calcite#5434, merged) makes RelBuilder.fields(Iterable<String>) look the names up in one pass. It should ship in the next Calcite release, likely 1.43.0 (the Jira's current fix version). We are on 1.42.0.
| Command | Code | Status |
|---|---|---|
fields with * or a wildcard; dropping flattened subfields |
expandProjectFields, tryToRemoveNestedFields |
Fixed in #5913, #5956 |
convert |
buildConversionProjection |
Fixed in #5960 |
replace |
visitReplace |
Fixed in #5961 |
eval writing to an existing object field (*) |
dropStructChildrenFor |
Open |
flatten |
visitFlatten |
Open |
transpose |
visitTranspose: type check, unpivot |
Open |
appendcol |
visitAppendCol |
Open |
addtotals, addcoltotals |
buildAddRowTotalAggregate |
Open |
(*) Also rex, parse, grok, patterns, bin, trendline, foreach, spath and nomv, which add fields through the same projectPlusOverriding, when the new field has the name of an existing object field.
Before
Each open command above calls field(String) once per name. On a 20,000-field input they take 3 to 6 s to analyze, against 20 ms for eval of a new field, and the time grows about 4 times each time the field count doubles. The fixed commands use buildFieldIndex instead.
After
Once we are on a Calcite release that includes CALCITE-7953:
- In
dropStructChildrenFor,visitTranspose,visitFlattenandbuildAddRowTotalAggregate, replace the per-namefield(String)calls with onerelBuilder.fields(names)call. appendcolalready callsfields(names), so it gets faster without a code change when the subsearch adds many fields.- Keep
buildFieldIndex(field expansion,convert,replace). Calcite still looks names up one at a time when the input's field names differ from its row type's, for example right after a join with repeated names, whilebuildFieldIndexis linear in every case. - Check that the plans are unchanged and that the cases in the appendix grow linearly.
These sites can also be fixed before the upgrade by resolving the fields by position, as convert and replace were.
Two O(n·m) costs in our own code are not covered by the Calcite change and need separate fixes:
appendcolfilters the subsearch's fields withmainFields.containson a list: 2.2 s at 20,000 fields when the subsearch keeps the main search's fields.addtotalsandaddcoltotalsfind numeric fields with a case-insensitivegetFieldper field (isNumericFieldName), which scans the fields each time: about 0.9 s left at 20,000 fields.
Reference
- CALCITE-7953, apache/calcite#5434, merged as apache/calcite@602e9dd
- #5913, #5956: field expansion and flattened subfields
- #5958, #5960:
convert - #5959, #5961:
replace
Appendix: measurements
A unit test in ppl based on CalcitePPLAbstractTest, using the table from CalcitePPLWideNestedSchemaTest: an ATTRS object, n flattened ATTRS.F* leaves and a few scalar columns. Times are for getRelNode (parse and analyze), with JVM assertions off, best of two runs. Before is main (e3c8ef9). After resolves the same fields by position in a local patch, which is what fields(names) does after the upgrade; that run went first, so its JIT was colder.
Query, after source=WIDE_n | |
Before, n = 5,000 | Before, n = 10,000 | Before, n = 20,000 | After, n = 20,000 |
|---|---|---|---|---|
eval Z = 1 (baseline) |
3 ms | 9 ms | 20 ms | n/a |
eval ATTRS = 1 |
195 ms | 762 ms | 3,035 ms | 37 ms |
flatten ATTRS |
202 ms | 781 ms | 3,020 ms | 81 ms |
fields ATTRS.F* | transpose 3 |
408 ms | 1,544 ms | 6,019 ms | 178 ms |
fields NAME | appendcol [ fields ATTRS.F* ] |
199 ms | 765 ms | 2,999 ms | 59 ms |
appendcol [ eval Z = 1 ] |
151 ms | 570 ms | 2,204 ms | 2,208 ms |
addtotals |
260 ms | 1,014 ms | 3,914 ms | 906 ms |
addcoltotals |
275 ms | 1,052 ms | 3,948 ms | 996 ms |
The fixed commands, as measured in their PRs:
convert(#5960) andreplace(#5961),source=wide_14000 | ... | head 10on a cluster: 896 ms → 38 ms and 900 ms → 32 ms.- Field expansion (#5956), a microbenchmark of the lookup loop at 8,000 fields: 496 ms → 0.88 ms.
- Ngôn ngữ chính
- Java
- Star
- 176
- Fork
- 237
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 34
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
-
bug untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
opensearch-project/sql#5990 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
opensearch-project/sql#5983 ·
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 107 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 64 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
-
calcite enhancement Meta performance PPL untriaged
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 8/100
opensearch-project/sql#5991 ·
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ự
-
NeoForge 安装任务的子任务描述有误Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
PCL-Community/PCL-CE#3907 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 2 ngày
-
area/dependencies area/dependencies/quarkus backport/26.6 backport/26.8 kind/cve severity/critical source/scan-dependencies status/triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
docker-to-squash.py: check_dependencies should find mksquashfs on PATHCó thể đã có người làm @linzch3 đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
chore
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
lugassawan/swe-workbench#841 ·