-
Notifications
You must be signed in to change notification settings - Fork 210
[BugFix] Fix bin/chart NPE with null values (#5174) #5334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ac9092c
7edbc20
1f7053d
d41e598
ccb3283
b423fcf
2c288d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,25 +30,3 @@ Fix a PPL bug end-to-end or follow up on an existing PR. | |
|
|
||
| **Related files:** [`.claude/harness/ppl-bugfix-harness.md`](.claude/harness/ppl-bugfix-harness.md) | ||
|
|
||
| --- | ||
|
|
||
| ## `/dedupe` | ||
|
|
||
| Find duplicate GitHub issues for a given issue. | ||
|
|
||
|
Comment on lines
-33
to
-38
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this removing on purpose?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, #5319 has migrate to reuse the workflow in opensearch-build. The original dedupe workflow has been migrated to that repo for reusing across openseach projects. |
||
| **Usage:** | ||
|
|
||
| ``` | ||
| /dedupe 1234 | ||
| ``` | ||
|
|
||
| **What it does:** | ||
|
|
||
| 1. Reads the target issue | ||
| 2. Runs 3+ parallel search strategies to find potential duplicates (only older issues) | ||
| 3. Verifies candidates by reading each one | ||
| 4. Posts a structured comment on the issue listing 1-3 confirmed duplicates (if any) | ||
|
|
||
| **Skips:** closed issues, broad feedback issues, issues already checked | ||
|
|
||
| **Related files:** [`scripts/comment-on-duplicates.sh`](scripts/comment-on-duplicates.sh) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package org.opensearch.sql.calcite.remote; | ||
|
|
||
| import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK_WITH_NULL_VALUES; | ||
| import static org.opensearch.sql.util.MatcherUtils.rows; | ||
| import static org.opensearch.sql.util.MatcherUtils.schema; | ||
| import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; | ||
| import static org.opensearch.sql.util.MatcherUtils.verifySchema; | ||
|
|
||
| import java.io.IOException; | ||
| import org.json.JSONObject; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.opensearch.sql.ppl.PPLIntegTestCase; | ||
|
|
||
| /** Integration test for GitHub issue #5174: bin/chart NPE with null values. */ | ||
| public class CalciteBinChartNullIT extends PPLIntegTestCase { | ||
| @Override | ||
| public void init() throws Exception { | ||
| super.init(); | ||
| enableCalcite(); | ||
| loadIndex(Index.BANK_WITH_NULL_VALUES); | ||
| } | ||
|
|
||
| @Test | ||
| public void testBinThenChartWithNullValuesShouldNotCauseNPE() throws IOException { | ||
| // bin balance span=10000 produces null for documents without a balance field. | ||
| // chart count() over bal_bin by gender should handle these null bin values safely. | ||
| JSONObject result = | ||
| executeQuery( | ||
| String.format( | ||
| "source=%s | bin balance span=10000 as bal_bin" | ||
| + " | chart count() over bal_bin by gender", | ||
| TEST_INDEX_BANK_WITH_NULL_VALUES)); | ||
| verifySchema( | ||
| result, | ||
| schema("bal_bin", "string"), | ||
| schema("gender", "string"), | ||
| schema("count()", "bigint")); | ||
| // Should only contain rows for non-null balance values (4 records with balance) | ||
| verifyDataRows( | ||
| result, | ||
| rows("0-10000", "M", 1), | ||
| rows("30000-40000", "F", 1), | ||
| rows("30000-40000", "M", 1), | ||
| rows("40000-50000", "F", 1)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testBinThenChartSingleGroupWithNullValues() throws IOException { | ||
| // chart with only row split (no column split): the simpler sort path | ||
| JSONObject result = | ||
| executeQuery( | ||
| String.format( | ||
| "source=%s | bin balance span=10000 as bal_bin | chart count() over bal_bin", | ||
| TEST_INDEX_BANK_WITH_NULL_VALUES)); | ||
| verifySchema(result, schema("bal_bin", "string"), schema("count()", "bigint")); | ||
| verifyDataRows(result, rows("0-10000", 1), rows("30000-40000", 2), rows("40000-50000", 1)); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| setup: | ||
| - do: | ||
| query.settings: | ||
| body: | ||
| transient: | ||
| plugins.calcite.enabled: true | ||
|
|
||
| - do: | ||
| indices.create: | ||
| index: issue5174 | ||
| body: | ||
| settings: | ||
| number_of_shards: 1 | ||
| number_of_replicas: 0 | ||
| mappings: | ||
| properties: | ||
| count: | ||
| type: integer | ||
| category: | ||
| type: keyword | ||
| subcategory: | ||
| type: keyword | ||
| value: | ||
| type: double | ||
| ts: | ||
| type: date | ||
|
|
||
| - do: | ||
| bulk: | ||
| refresh: true | ||
| body: | ||
| - '{"index": {"_index": "issue5174", "_id": "1"}}' | ||
| - '{"count": 1, "category": "A", "subcategory": "X", "value": 10.5, "ts": "2024-01-01"}' | ||
| - '{"index": {"_index": "issue5174", "_id": "2"}}' | ||
| - '{"count": 2, "category": "A", "subcategory": "Y", "value": 20.3, "ts": "2024-01-02"}' | ||
| - '{"index": {"_index": "issue5174", "_id": "3"}}' | ||
| - '{"count": 10, "category": "B", "subcategory": "X", "value": 100.0, "ts": "2024-01-03"}' | ||
| - '{"index": {"_index": "issue5174", "_id": "4"}}' | ||
| - '{"count": null, "category": "B", "subcategory": "Y", "value": null, "ts": "2024-01-04"}' | ||
|
|
||
| --- | ||
| teardown: | ||
| - do: | ||
| indices.delete: | ||
| index: issue5174 | ||
| ignore_unavailable: true | ||
| - do: | ||
| query.settings: | ||
| body: | ||
| transient: | ||
| plugins.calcite.enabled: false | ||
|
|
||
| --- | ||
| "Issue 5174: bin then chart with null values should not cause NPE": | ||
| - skip: | ||
| features: | ||
| - headers | ||
| - do: | ||
| headers: | ||
| Content-Type: 'application/json' | ||
| ppl: | ||
| body: | ||
| query: source=issue5174 | bin value span=50 as val_bin | chart count() over val_bin by category | ||
|
|
||
| - match: { total: 2 } | ||
| - match: { schema: [ { name: val_bin, type: string }, { name: category, type: string }, { name: "count()", type: bigint } ] } | ||
| - match: { datarows: [ [ "0-50", "A", 2 ], [ "100-150", "B", 1 ] ] } | ||
|
|
||
| --- | ||
| "Issue 5174: bin then chart with single group and null values": | ||
| - skip: | ||
| features: | ||
| - headers | ||
| - do: | ||
| headers: | ||
| Content-Type: 'application/json' | ||
| ppl: | ||
| body: | ||
| query: source=issue5174 | bin value span=50 as val_bin | chart count() over val_bin | ||
|
|
||
| - match: { total: 2 } | ||
| - match: { schema: [ { name: val_bin, type: string }, { name: "count()", type: bigint } ] } | ||
| - match: { datarows: [ [ "0-50", 2 ], [ "100-150", 1 ] ] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is from skill self-improving after receiving the feedback of PR_REVEW workflow comments.