File tree Expand file tree Collapse file tree
test/java/org/opensearch/sql/ppl/parser Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -610,12 +610,26 @@ wildcard
610610
611611keywordsCanBeId
612612 : D // OD SQL and ODBC special
613- | statsFunctionName
614- | TIMESTAMP | DATE | TIME
615- | FIRST | LAST
616613 | 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
621635 ;
Original file line number Diff line number Diff line change @@ -813,6 +813,11 @@ public void functionNameCanBeUsedAsIdentifier() {
813813 "ABS | CEIL | CEILING | CONV | CRC32 | E | EXP | FLOOR | LN | LOG"
814814 + " | LOG10 | LOG2 | MOD | PI |POW | POWER | RAND | ROUND | SIGN | SQRT | TRUNCATE "
815815 + "| 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" );
816821 }
817822
818823 void assertFunctionNameCouldBeId (String antlrFunctionName ) {
@@ -833,4 +838,26 @@ void assertFunctionNameCouldBeId(String antlrFunctionName) {
833838 ));
834839 }
835840 }
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+ }
836863}
You can’t perform that action at this time.
0 commit comments