File tree Expand file tree Collapse file tree 2 files changed +48
-7
lines changed
test/java/org/opensearch/sql/ppl/parser Expand file tree Collapse file tree 2 files changed +48
-7
lines changed Original file line number Diff line number Diff line change @@ -610,12 +610,26 @@ wildcard
610
610
611
611
keywordsCanBeId
612
612
: D // OD SQL and ODBC special
613
- | statsFunctionName
614
- | TIMESTAMP | DATE | TIME
615
- | FIRST | LAST
616
613
| timespanUnit | SPAN
617
- | dateAndTimeFunctionBase
618
- | textFunctionBase
619
- | mathematicalFunctionBase
620
- | positionFunctionName
614
+ | evalFunctionName
615
+ | relevanceArgName
616
+ | intervalUnit
617
+ // commands
618
+ | SEARCH | DESCRIBE | SHOW | FROM | WHERE | FIELDS | RENAME | STATS | DEDUP | SORT | EVAL | HEAD | TOP | RARE
619
+ | PARSE | METHOD | REGEX | PUNCT | GROK | PATTERN | PATTERNS | NEW_FIELD | KMEANS | AD | ML
620
+ // commands assist keywords
621
+ | SOURCE | INDEX | DESC | DATASOURCES
622
+ // CLAUSEKEYWORDS
623
+ | SORTBY
624
+ // FIELDKEYWORDSAUTO
625
+ | STR | IP | NUM
626
+ // ARGUMENT KEYWORDS
627
+ | KEEPEMPTY | CONSECUTIVE | DEDUP_SPLITVALUES | PARTITIONS | ALLNUM | DELIM | CENTROIDS | ITERATIONS | DISTANCE_TYPE
628
+ | NUMBER_OF_TREES | SHINGLE_SIZE | SAMPLE_SIZE | OUTPUT_AFTER | TIME_DECAY | ANOMALY_RATE | CATEGORY_FIELD
629
+ | TIME_FIELD | TIME_ZONE | TRAINING_DATA_SIZE | ANOMALY_SCORE_THRESHOLD
630
+ // AGGREGATIONS
631
+ | AVG | COUNT | DISTINCT_COUNT | ESTDC | ESTDC_ERROR | MAX | MEAN | MEDIAN | MIN | MODE | RANGE | STDEV | STDEVP
632
+ | SUM | SUMSQ | VAR_SAMP | VAR_POP | STDDEV_SAMP | STDDEV_POP | PERCENTILE | TAKE | FIRST | LAST | LIST | VALUES
633
+ | EARLIEST | EARLIEST_TIME | LATEST | LATEST_TIME | PER_DAY | PER_HOUR | PER_MINUTE | PER_SECOND | RATE | SPARKLINE
634
+ | C | DC
621
635
;
Original file line number Diff line number Diff line change @@ -813,6 +813,11 @@ public void functionNameCanBeUsedAsIdentifier() {
813
813
"ABS | CEIL | CEILING | CONV | CRC32 | E | EXP | FLOOR | LN | LOG"
814
814
+ " | LOG10 | LOG2 | MOD | PI |POW | POWER | RAND | ROUND | SIGN | SQRT | TRUNCATE "
815
815
+ "| ACOS | ASIN | ATAN | ATAN2 | COS | COT | DEGREES | RADIANS | SIN | TAN" );
816
+ assertFunctionNameCouldBeId (
817
+ "SEARCH | DESCRIBE | SHOW | FROM | WHERE | FIELDS | RENAME | STATS "
818
+ + "| DEDUP | SORT | EVAL | HEAD | TOP | RARE | PARSE | METHOD | REGEX | PUNCT | GROK "
819
+ + "| PATTERN | PATTERNS | NEW_FIELD | KMEANS | AD | ML | SOURCE | INDEX | D | DESC "
820
+ + "| DATASOURCES" );
816
821
}
817
822
818
823
void assertFunctionNameCouldBeId (String antlrFunctionName ) {
@@ -833,4 +838,26 @@ void assertFunctionNameCouldBeId(String antlrFunctionName) {
833
838
));
834
839
}
835
840
}
841
+
842
+ // https://github.com/opensearch-project/sql/issues/1318
843
+ @ Test
844
+ public void indexCanBeId () {
845
+ assertEqual ("source = index | stats count() by index" ,
846
+ agg (
847
+ relation ("index" ),
848
+ exprList (
849
+ alias (
850
+ "count()" ,
851
+ aggregate ("count" , AllFields .of ())
852
+ )
853
+ ),
854
+ emptyList (),
855
+ exprList (
856
+ alias (
857
+ "index" ,
858
+ field ("index" )
859
+ )),
860
+ defaultStatsArgs ()
861
+ ));
862
+ }
836
863
}
You can’t perform that action at this time.
0 commit comments