@@ -503,35 +503,17 @@ public void testStringAsIndexPattern() {
503503 clusterAndIndexAsIndexPattern (command , "*:index*" );
504504 clusterAndIndexAsIndexPattern (command , "*:*" );
505505 if (EsqlCapabilities .Cap .INDEX_COMPONENT_SELECTORS .isEnabled ()) {
506+ assertStringAsIndexPattern ("foo::*" , command + " foo::*" );
506507 assertStringAsIndexPattern ("foo::data" , command + " foo::data" );
507508 assertStringAsIndexPattern ("foo::failures" , command + " foo::failures" );
508- assertStringAsIndexPattern ("foo::*" , command + " foo::*" );
509- assertStringAsIndexPattern ("cluster:foo::data" , command + " cluster:foo::data" );
510- assertStringAsIndexPattern ("cluster:foo::failures" , command + " cluster:foo::failures" );
511- assertStringAsIndexPattern ("cluster:foo::*" , command + " cluster:foo::*" );
512- assertStringAsIndexPattern ("foo::*" , command + " foo::*" );
513- assertStringAsIndexPattern ("cluster:foo::*" , command + " cluster:\" foo\" ::*" );
514- assertStringAsIndexPattern ("cluster:foo::*" , command + " \" cluster:foo\" ::*" );
515- assertStringAsIndexPattern ("cluster:foo::*" , command + " \" cluster:foo::*\" " );
516- assertStringAsIndexPattern ("cluster:foo::data" , command + " cluster:\" foo\" ::data" );
517- assertStringAsIndexPattern ("cluster:foo::data" , command + " \" cluster:foo\" ::data" );
518- assertStringAsIndexPattern ("cluster:foo::data" , command + " \" cluster:foo::data\" " );
519- assertStringAsIndexPattern ("cluster:foo::failures" , command + " cluster:\" foo\" ::failures" );
520- assertStringAsIndexPattern ("cluster:foo::failures" , command + " \" cluster:foo\" ::failures" );
521- assertStringAsIndexPattern ("cluster:foo::failures" , command + " \" cluster:foo::failures\" " );
509+ assertStringAsIndexPattern ("cluster:foo::failures" , command + " cluster:\" foo::failures\" " );
522510 assertStringAsIndexPattern ("*,-foo::*" , command + " *, \" -foo\" ::*" );
523511 assertStringAsIndexPattern ("*,-foo::*" , command + " *, \" -foo::*\" " );
524512 assertStringAsIndexPattern ("*::*" , command + " *::*" );
525513 assertStringAsIndexPattern (
526514 "<logstash-{now/M{yyyy.MM}}>::*,<logstash-{now/d{yyyy.MM.dd|+12:00}}>::failures" ,
527515 command + " <logstash-{now/M{yyyy.MM}}>::*, \" <logstash-{now/d{yyyy.MM.dd|+12:00}}>\" ::failures"
528516 );
529- clusterAndIndexAsIndexPattern (command , "cluster:index::data" );
530- clusterAndIndexAsIndexPattern (command , "cluster:*::data" );
531- clusterAndIndexAsIndexPattern (command , "*:index::data" );
532- clusterAndIndexAsIndexPattern (command , "*:index::*" );
533- clusterAndIndexAsIndexPattern (command , "*:index*::*" );
534- clusterAndIndexAsIndexPattern (command , "*:*::*" );
535517 }
536518 }
537519 }
@@ -618,11 +600,60 @@ public void testInvalidCharacterInIndexPattern() {
618600 if (EsqlCapabilities .Cap .INDEX_COMPONENT_SELECTORS .isEnabled () && command .contains ("LOOKUP_🐔" ) == false ) {
619601 expectInvalidIndexNameErrorWithLineNumber (command , "index::dat" , lineNumber );
620602 expectInvalidIndexNameErrorWithLineNumber (command , "index::failure" , lineNumber );
621- expectError (LoggerMessageFormat .format (null , command , "\" index:::data\" " ), lineNumber + "Invalid index name [index:::data" );
622- expectError (
623- LoggerMessageFormat .format (null , command , "\" index::::data\" " ),
624- lineNumber + "Invalid index name [index::::data"
603+
604+ // Cluster name cannot be combined with selector yet.
605+ var parseLineNumber = command .contains ("FROM" ) ? 6 : 9 ;
606+ expectDoubleColonErrorWithLineNumber (command , "cluster:foo::*" , parseLineNumber + 11 );
607+ expectDoubleColonErrorWithLineNumber (command , "cluster:foo::data" , parseLineNumber + 11 );
608+ expectDoubleColonErrorWithLineNumber (command , "cluster:foo::failures" , parseLineNumber + 11 );
609+
610+ expectDoubleColonErrorWithLineNumber (command , "cluster:\" foo\" ::*" , parseLineNumber + 13 );
611+ expectDoubleColonErrorWithLineNumber (command , "cluster:\" foo\" ::data" , parseLineNumber + 13 );
612+ expectDoubleColonErrorWithLineNumber (command , "cluster:\" foo\" ::failures" , parseLineNumber + 13 );
613+
614+ // TODO: Edge case that will be invalidated in follow up (https://github.com/elastic/elasticsearch/issues/122651)
615+ // expectDoubleColonErrorWithLineNumber(command, "\"cluster:foo\"::*", parseLineNumber + 13);
616+ // expectDoubleColonErrorWithLineNumber(command, "\"cluster:foo\"::data", parseLineNumber + 13);
617+ // expectDoubleColonErrorWithLineNumber(command, "\"cluster:foo\"::failures", parseLineNumber + 13);
618+
619+ expectErrorWithLineNumber (
620+ command ,
621+ "\" cluster:foo::*\" " ,
622+ lineNumber ,
623+ "Cannot specify remote cluster and selector in same pattern"
624+ );
625+ expectErrorWithLineNumber (
626+ command ,
627+ "\" cluster:foo::data\" " ,
628+ lineNumber ,
629+ "Cannot specify remote cluster and selector in same pattern"
625630 );
631+ expectErrorWithLineNumber (
632+ command ,
633+ "\" cluster:foo::failures\" " ,
634+ lineNumber ,
635+ "Cannot specify remote cluster and selector in same pattern"
636+ );
637+
638+ // Wildcards
639+ expectDoubleColonErrorWithLineNumber (command , "cluster:*::data" , parseLineNumber + 9 );
640+ expectDoubleColonErrorWithLineNumber (command , "*:index::data" , parseLineNumber + 7 );
641+ expectDoubleColonErrorWithLineNumber (command , "*:index::*" , parseLineNumber + 7 );
642+ expectDoubleColonErrorWithLineNumber (command , "*:index*::*" , parseLineNumber + 8 );
643+ expectDoubleColonErrorWithLineNumber (command , "*:*::*" , parseLineNumber + 3 );
644+
645+ // Too many colons
646+ expectInvalidIndexNameErrorWithLineNumber (command , "\" index:::data\" " , lineNumber , "index:" , "must not contain ':'" );
647+ expectInvalidIndexNameErrorWithLineNumber (
648+ command ,
649+ "\" index::::data\" " ,
650+ lineNumber ,
651+ "index::::data" ,
652+ "Invalid usage of :: separator"
653+ );
654+
655+ // TODO: Edge case that will be invalidated in follow up (https://github.com/elastic/elasticsearch/issues/122651)
656+ expectDoubleColonErrorWithLineNumber (command , "cluster:\" index,index2\" ::failures" , parseLineNumber + 22 );
626657 }
627658 }
628659
@@ -660,8 +691,8 @@ public void testInvalidCharacterInIndexPattern() {
660691 command ,
661692 "\" indexpattern, --index::data\" " ,
662693 commands .get (command ),
663- "-index::data " ,
664- "must not contain ': '"
694+ "-index" ,
695+ "must not start with '_', '-', or '+ '"
665696 );
666697 }
667698 }
@@ -3109,7 +3140,7 @@ public void testInvalidJoinPatterns() {
31093140 joinPattern = maybeQuote (joinPattern + "::garbage" );
31103141 expectError (
31113142 "FROM " + randomIndexPatterns () + " | JOIN " + joinPattern + " ON " + randomIdentifier (),
3112- "mismatched input ': ' expecting {"
3143+ "mismatched input 'JOIN ' expecting {"
31133144 );
31143145 }
31153146 }
0 commit comments