@@ -793,11 +793,8 @@ public void testInvalidQuotingAsFromIndexPattern() {
793793 expectError ("FROM \" foo\" bar\" " , ": token recognition error at: '\" '" );
794794 expectError ("FROM \" foo\" \" bar\" " , ": extraneous input '\" bar\" ' expecting <EOF>" );
795795
796- expectError ("FROM \" \" \" foo\" \" \" bar\" \" \" " , ": mismatched input 'bar' expecting {<EOF>, '|', ',', OPENING_BRACKET, 'metadata'}" );
797- expectError (
798- "FROM \" \" \" foo\" \" \" \" \" \" bar\" \" \" " ,
799- ": mismatched input '\" bar\" ' expecting {<EOF>, '|', ',', OPENING_BRACKET, 'metadata'}"
800- );
796+ expectError ("FROM \" \" \" foo\" \" \" bar\" \" \" " , ": mismatched input 'bar' expecting {<EOF>, '|', ',', '[', 'metadata'}" );
797+ expectError ("FROM \" \" \" foo\" \" \" \" \" \" bar\" \" \" " , ": mismatched input '\" bar\" ' expecting {<EOF>, '|', ',', '[', 'metadata'}" );
801798 }
802799
803800 public void testInvalidQuotingAsMetricsIndexPattern () {
@@ -1087,7 +1084,7 @@ public void testMetadataFieldOnOtherSources() {
10871084 expectError ("show info metadata _index" , "line 1:11: token recognition error at: 'm'" );
10881085 expectError (
10891086 "explain [from foo] metadata _index" ,
1090- "line 1:20: mismatched input 'metadata' expecting {'|', ',', OPENING_BRACKET , ']', 'metadata'}"
1087+ "line 1:20: mismatched input 'metadata' expecting {'|', ',', '[' , ']', 'metadata'}"
10911088 );
10921089 }
10931090
@@ -3044,7 +3041,7 @@ public void testNamedFunctionArgumentInInvalidPositions() {
30443041 String map = "{\" option1\" :\" string\" , \" option2\" :1}" ;
30453042
30463043 Map <String , String > commands = Map .ofEntries (
3047- Map .entry ("from {}" , "line 1:7: mismatched input '\" option1\" ' expecting {<EOF>, '|', ',', OPENING_BRACKET , 'metadata'}" ),
3044+ Map .entry ("from {}" , "line 1:7: mismatched input '\" option1\" ' expecting {<EOF>, '|', ',', '[' , 'metadata'}" ),
30483045 Map .entry ("row x = {}" , "line 1:9: extraneous input '{' expecting {QUOTED_STRING, INTEGER_LITERAL" ),
30493046 Map .entry ("eval x = {}" , "line 1:22: extraneous input '{' expecting {QUOTED_STRING, INTEGER_LITERAL" ),
30503047 Map .entry ("where x > {}" , "line 1:23: no viable alternative at input 'x > {'" ),
@@ -3951,4 +3948,19 @@ public void testUnclosedParenthesis() {
39513948 expectError (q , "Invalid query" );
39523949 }
39533950 }
3951+
3952+ // [ and ( are used to trigger a double mode causing their symbol name (instead of text) to be used in error reporting
3953+ // this test checks that their are properly replaced in the error message
3954+ public void testPreserveParanthesis () {
3955+ // test for (
3956+ expectError ("row a = 1 not in" , "line 1:17: mismatched input '<EOF>' expecting '('" );
3957+ expectError ("row a = 1 | where a not in" , "line 1:27: mismatched input '<EOF>' expecting '('" );
3958+ expectError ("row a = 1 | where a not in (1" , "line 1:30: mismatched input '<EOF>' expecting {',', ')'}" );
3959+ expectError ("row a = 1 | where a not in [1" , "line 1:28: missing '(' at '['" );
3960+ expectError ("row a = 1 | where a not in 123" , "line 1:28: missing '(' at '123'" );
3961+ // test for [
3962+ expectError ("explain" , "line 1:8: mismatched input '<EOF>' expecting '['" );
3963+ expectError ("explain ]" , "line 1:9: token recognition error at: ']'" );
3964+ expectError ("explain [row x = 1" , "line 1:19: missing ']' at '<EOF>'" );
3965+ }
39543966}
0 commit comments