Skip to content

Commit 1579846

Browse files
committed
Allow flexible parameter positions for chart and timechart
Signed-off-by: Yuanchun Shen <[email protected]>
1 parent 595f4f9 commit 1579846

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteChartCommandIT.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ public void testChartLimit0WithUseOther() throws IOException {
169169
JSONObject result =
170170
executeQuery(
171171
String.format(
172-
"source=%s | chart limit=0 useother=true otherstr='max_among_other'"
173-
+ " max(severityNumber) over flags by severityText",
172+
"source=%s | chart max(severityNumber) over flags by severityText limit=0"
173+
+ " useother=true otherstr='max_among_other'",
174174
TEST_INDEX_OTEL_LOGS));
175175
verifySchema(
176176
result,
@@ -250,7 +250,8 @@ public void testChartLimitTopWithMinAgg() throws IOException {
250250
JSONObject result =
251251
executeQuery(
252252
String.format(
253-
"source=%s | chart limit=top2 min(severityNumber) over flags by severityText",
253+
"source=%s | chart limit=top2 min(severityNumber) over flags by severityText"
254+
+ " useother=true otherstr='OTHER'",
254255
TEST_INDEX_OTEL_LOGS));
255256
verifySchema(
256257
result,
@@ -306,8 +307,8 @@ public void testChartUseNullFalseWithNullStr() throws IOException {
306307
JSONObject result =
307308
executeQuery(
308309
String.format(
309-
"source=%s | chart usenull=false nullstr='not_shown' count() over gender by age"
310-
+ " span=10",
310+
"source=%s | chart usenull=false count() over gender by age "
311+
+ " span=10 nullstr='not_shown'",
311312
TEST_INDEX_BANK_WITH_NULL_VALUES));
312313
verifySchema(
313314
result, schema("gender", "string"), schema("age", "string"), schema("count()", "bigint"));

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteTimechartCommandIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public void testTimechartWithMissingHostValues() throws IOException {
361361
@Test
362362
public void testTimechartWithNullAndOther() throws IOException {
363363
JSONObject result =
364-
executeQuery("source=events_null | timechart span=1d limit=2 count() by host");
364+
executeQuery("source=events_null | timechart count() by host span=1d limit=2");
365365

366366
verifySchema(
367367
result,
@@ -380,7 +380,7 @@ public void testTimechartWithNullAndOther() throws IOException {
380380
@Test
381381
public void testTimechartWithNullAndLimit() throws IOException {
382382
JSONObject result =
383-
executeQuery("source=events_null | timechart span=1d limit=3 count() by host");
383+
executeQuery("source=events_null | timechart span=1d count() by host limit=3");
384384

385385
verifySchema(
386386
result,

ppl/src/main/antlr/OpenSearchPPLParser.g4

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ reverseCommand
289289
;
290290

291291
chartCommand
292-
: CHART chartOptions* statsAggTerm (OVER rowSplit)? (BY columnSplit)?
293-
| CHART chartOptions* statsAggTerm BY rowSplit (COMMA)? columnSplit
292+
: CHART chartOptions* statsAggTerm (OVER rowSplit)? (BY columnSplit)? chartOptions*
293+
| CHART chartOptions* statsAggTerm BY rowSplit (COMMA)? columnSplit chartOptions*
294294
;
295295

296296
chartOptions
@@ -311,7 +311,7 @@ columnSplit
311311
;
312312

313313
timechartCommand
314-
: TIMECHART timechartParameter* statsAggTerm (BY fieldExpression)?
314+
: TIMECHART timechartParameter* statsAggTerm (BY fieldExpression)? timechartParameter*
315315
;
316316

317317
timechartParameter

0 commit comments

Comments
 (0)