@@ -496,12 +496,15 @@ public void testStringAsIndexPattern() {
496496 assertStringAsIndexPattern ("`backtick`,``multiple`back``ticks```" , command + " `backtick`, ``multiple`back``ticks```" );
497497 assertStringAsIndexPattern ("test,metadata,metaata,.metadata" , command + " test,\" metadata\" , metaata, .metadata" );
498498 assertStringAsIndexPattern (".dot" , command + " .dot" );
499- String lineNumber = command .equals ("FROM" ) ? "line 1:14: " : "line 1:12: " ;
499+
500+ String lineNumber = command .equals ("FROM" ) ? "line 1:14: " : "line 1:17: " ;
500501 expectErrorWithLineNumber (
501502 command + " cluster:\" index|pattern\" " ,
502503 " cluster:\" index|pattern\" " ,
503504 lineNumber ,
504- "mismatched input '\" index|pattern\" ' expecting UNQUOTED_SOURCE"
505+ command .equals ("FROM" )
506+ ? "mismatched input '\" index|pattern\" ' expecting UNQUOTED_SOURCE"
507+ : "missing UNQUOTED_SOURCE at '\" index|pattern\" '"
505508 );
506509 assertStringAsIndexPattern ("*:index|pattern" , command + " \" *:index|pattern\" " );
507510 clusterAndIndexAsIndexPattern (command , "cluster:index" );
@@ -519,29 +522,28 @@ public void testStringAsIndexPattern() {
519522 command + " cluster:\" foo::data\" " ,
520523 " cluster:\" foo::data\" " ,
521524 lineNumber ,
522- "mismatched input '\" foo::data\" ' expecting UNQUOTED_SOURCE"
525+ command .equals ("FROM" )
526+ ? "mismatched input '\" foo::data\" ' expecting UNQUOTED_SOURCE"
527+ : "missing UNQUOTED_SOURCE at '\" foo::data\" "
523528 );
524529 expectErrorWithLineNumber (
525530 command + " cluster:\" foo::failures\" " ,
526531 " cluster:\" foo::failures\" " ,
527532 lineNumber ,
528- "mismatched input '\" foo::failures\" ' expecting UNQUOTED_SOURCE"
529- );
530- lineNumber = command .equals ("FROM" ) ? "line 1:15: " : "line 1:13: " ;
531- expectErrorWithLineNumber (
532- command + " *, \" -foo\" ::data" ,
533- " *, \" -foo\" ::data" ,
534- lineNumber ,
535- "mismatched input '::' expecting {<EOF>, '|', ',', 'metadata'}"
533+ command .equals ("FROM" )
534+ ? "mismatched input '\" foo::failures\" ' expecting UNQUOTED_SOURCE"
535+ : "missing UNQUOTED_SOURCE at '\" foo::failures\" '"
536536 );
537+ lineNumber = command .equals ("FROM" ) ? "line 1:15: " : "line 1:18: " ;
538+ expectErrorWithLineNumber (command + " *, \" -foo\" ::data" , " *, \" -foo\" ::data" , lineNumber , "mismatched input '::'" );
537539 assertStringAsIndexPattern ("*,-foo::data" , command + " *, \" -foo::data\" " );
538540 assertStringAsIndexPattern ("*::data" , command + " *::data" );
539- lineNumber = command .equals ("FROM" ) ? "line 1:79: " : "line 1:77 : " ;
541+ lineNumber = command .equals ("FROM" ) ? "line 1:79: " : "line 1:82 : " ;
540542 expectErrorWithLineNumber (
541543 command + " \" <logstash-{now/M{yyyy.MM}}>::data,<logstash-{now/d{yyyy.MM.dd|+12:00}}>\" ::failures" ,
542544 " \" <logstash-{now/M{yyyy.MM}}>::data,<logstash-{now/d{yyyy.MM.dd|+12:00}}>\" ::failures" ,
543545 lineNumber ,
544- "mismatched input '::' expecting {<EOF>, '|', ',', 'metadata'} "
546+ "mismatched input '::'"
545547 );
546548 assertStringAsIndexPattern (
547549 "<logstash-{now/M{yyyy.MM}}>::data,<logstash-{now/d{yyyy.MM.dd|+12:00}}>::failures" ,
@@ -635,22 +637,33 @@ public void testInvalidCharacterInIndexPattern() {
635637 expectInvalidIndexNameErrorWithLineNumber (command , "index::failure" , lineNumber );
636638
637639 // Cluster name cannot be combined with selector yet.
638- var parseLineNumber = command .contains ("FROM" ) ? 6 : 9 ;
640+ int parseLineNumber = 6 ;
641+ if (command .startsWith ("METRICS" )) {
642+ parseLineNumber = 9 ;
643+ } else if (command .startsWith ("ROW" )) {
644+ parseLineNumber = 22 ;
645+ }
646+
639647 expectDoubleColonErrorWithLineNumber (command , "cluster:foo::data" , parseLineNumber + 11 );
640648 expectDoubleColonErrorWithLineNumber (command , "cluster:foo::failures" , parseLineNumber + 11 );
641649
642650 // Index pattern cannot be quoted if cluster string is present.
651+ var partialQuotingBeginOffset = parseLineNumber + 8 ;
643652 expectErrorWithLineNumber (
644653 command ,
645654 "cluster:\" foo\" ::data" ,
646- "line 1:14: " ,
647- "mismatched input '\" foo\" ' expecting UNQUOTED_SOURCE"
655+ "line 1:" + partialQuotingBeginOffset + ": " ,
656+ command .startsWith ("FROM" )
657+ ? "mismatched input '\" foo\" ' expecting UNQUOTED_SOURCE"
658+ : "missing UNQUOTED_SOURCE at '\" foo\" '"
648659 );
649660 expectErrorWithLineNumber (
650661 command ,
651662 "cluster:\" foo\" ::failures" ,
652- "line 1:14: " ,
653- "mismatched input '\" foo\" ' expecting UNQUOTED_SOURCE"
663+ "line 1:" + partialQuotingBeginOffset + ": " ,
664+ command .startsWith ("FROM" )
665+ ? "mismatched input '\" foo\" ' expecting UNQUOTED_SOURCE"
666+ : "missing UNQUOTED_SOURCE at '\" foo\" '"
654667 );
655668
656669 // TODO: Edge case that will be invalidated in follow up (https://github.com/elastic/elasticsearch/issues/122651)
@@ -699,8 +712,10 @@ public void testInvalidCharacterInIndexPattern() {
699712 expectErrorWithLineNumber (
700713 command ,
701714 "cluster:\" index,index2\" ::failures" ,
702- "line 1:14: " ,
703- "mismatched input '\" index,index2\" ' expecting UNQUOTED_SOURCE"
715+ "line 1:" + partialQuotingBeginOffset + ": " ,
716+ command .startsWith ("FROM" )
717+ ? "mismatched input '\" index,index2\" ' expecting UNQUOTED_SOURCE"
718+ : "missing UNQUOTED_SOURCE at '\" index,index2\" '"
704719 );
705720 }
706721 }
@@ -728,11 +743,13 @@ public void testInvalidCharacterInIndexPattern() {
728743 "-index" ,
729744 "must not start with '_', '-', or '+'"
730745 );
746+
747+ var partialQuotingBeginOffset = (command .startsWith ("FROM" ) ? 6 : 9 ) + 23 ;
731748 expectErrorWithLineNumber (
732749 command ,
733750 "indexpattern, \" --index\" ::data" ,
734- "line 1:29 : " ,
735- "mismatched input '::' expecting {<EOF>, '|', ',', 'metadata'} "
751+ "line 1:" + partialQuotingBeginOffset + " : " ,
752+ "mismatched input '::'"
736753 );
737754 expectInvalidIndexNameErrorWithLineNumber (
738755 command ,
@@ -767,11 +784,12 @@ public void testInvalidCharacterInIndexPattern() {
767784 clustersAndIndices (command , "*" , "-<--logstash-{now/M{yyyy.MM}}>::data" );
768785 clustersAndIndices (command , "index*" , "-<--logstash#-{now/M{yyyy.MM}}>::data" );
769786 // Throw on invalid date math
787+ var partialQuotingBeginOffset = (command .startsWith ("FROM" ) ? 6 : 9 ) + 25 ;
770788 expectDateMathErrorWithLineNumber (
771789 command ,
772790 "*, \" -<-logstash-{now/D}>\" ::data" ,
773- "line 1:31 : " ,
774- "mismatched input '::' expecting {<EOF>, '|', ',', 'metadata'} "
791+ "line 1:" + partialQuotingBeginOffset + " : " ,
792+ "mismatched input '::'"
775793 );
776794 expectDateMathErrorWithLineNumber (command , "*, -<-logstash-{now/D}>::data" , lineNumber , dateMathError );
777795 // Check that invalid selectors throw (they're resolved first in /_search, and always validated)
@@ -2529,7 +2547,7 @@ public void testInvalidAlias() {
25292547 }
25302548
25312549 public void testInvalidRemoteClusterPattern () {
2532- expectError ("from \" rem:ote\" :index" , "mismatched input ':' expecting {<EOF>, '|', ',', 'metadata'}" );
2550+ expectError ("from \" rem:ote\" :index" , "mismatched input ':' expecting {<EOF>, '|', ',', '[', ' metadata'}" );
25332551 }
25342552
25352553 private LogicalPlan unresolvedRelation (String index ) {
@@ -3229,10 +3247,10 @@ public void testInvalidJoinPatterns() {
32293247 {
32303248 var fromPatterns = randomIndexPattern ();
32313249 // Generate a syntactically invalid (partial quoted) pattern.
3232- var joinPattern = randomIdentifier () + ":" + quote (randomIndexPatterns (without (CROSS_CLUSTER )));
3250+ var joinPattern = randomIdentifier () + ":" + quote (randomIndexPattern (without (CROSS_CLUSTER )));
32333251 expectError (
32343252 "FROM " + fromPatterns + " | LOOKUP JOIN " + joinPattern + " ON " + randomIdentifier (),
3235- // Since the from pattern is partially quoted, we get an error at the beginning of the partially quoted
3253+ // Since the join pattern is partially quoted, we get an error at the beginning of the partially quoted
32363254 // index name that we're expecting an unquoted string.
32373255 "expecting UNQUOTED_SOURCE"
32383256 );
0 commit comments